Link to home
Start Free TrialLog in
Avatar of lexcio
lexcio

asked on

CS1026: ) expected

Hello,

I am trying to slowly transition from ASP to ASP.NET.  I am very unfamiliar with the .NET at this point.  A book I am reading provided the following sample code.  When I attempted to use it, I got the following error:

Compiler Error Message: CS1026: ) expected

Here is the sample code - note the error on line 5:
=============
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Web.Mail" %>

<Script runat="server">
Sub Button_Click(s As Object, e As EventArgs) '***The error occurs on this line
  SmtpMail.Send( _
    mailfrom.Text, _
    mailto.Text, _
    mailsubject.Text, _
    mailbody.Text )
End Sub
</Script>

<html>
<head><title>SendMail.aspx</title></head>
<body>

<h1>Send Mail:</h1>
<form runat="Server">

<b>From:</b>
<br>
<asp:TextBox
  ID="mailfrom"
  Columns="50"
  Runat="Server" />
<p>
<b>To:</b>
<br>
<asp:TextBox
  ID="mailto"
  Columns="50"
  Runat="Server" />
<p>
<b>Subject:</b>
<br>
<asp:TextBox
  ID="mailsubject"
  Columns="50"
  Runat="Server" />
<p>
<b>Body:</b>
<br>
<asp:TextBox
  ID="mailbody"
  TextMode="Multiline"
  Columns="50"
  Rows="10"
  Runat="Server" />
<p>
<asp:Button
  Text="Send!"
  OnClick="Button_Click"
  Runat="Server" />
</form>

</body>
</html>
==============
ASKER CERTIFIED SOLUTION
Avatar of Justin_W
Justin_W

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lexcio
lexcio

ASKER

Good catch,

Now line 6 is causing the problem.

System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.

Line 6:  
SmtpMail.Send( _

Any ideas?
This sounds like an issue for a separate question.  However:

You probably need to set the SMTP server explicitly before calling the SmtpMail.Send method.  E.g.:
   SmtpMail.SmtpServer = "smtp.YourProvider.com"
Avatar of lexcio

ASKER

ok.  sure.  let me set up a separate post... & you can elaborate there.
Avatar of lexcio

ASKER

Here is the new post:

https://www.experts-exchange.com/questions/21482868/SendUsing-configuration-invalid.html

Thanks for any help you can provide!