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>
==============
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
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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"
You probably need to set the SMTP server explicitly before calling the SmtpMail.Send method. E.g.:
SmtpMail.SmtpServer = "smtp.YourProvider.com"
ASKER
ok. sure. let me set up a separate post... & you can elaborate there.
ASKER
Here is the new post:
https://www.experts-exchange.com/questions/21482868/SendUsing-configuration-invalid.html
Thanks for any help you can provide!
https://www.experts-exchange.com/questions/21482868/SendUsing-configuration-invalid.html
Thanks for any help you can provide!
ASKER
Now line 6 is causing the problem.
System.Runtime.InteropServ
Line 6:
SmtpMail.Send( _
Any ideas?