Click here to Skip to main content
15,746,534 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

Pl send the mail sending coding in c#.i used the following coding but its getting error as below,so send any good working coding to send the email,

The specified string is not in the form required for an e-mail address.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: The specified string is not in the form required for an e-mail address.

Source Error:

Line 67:
Line 68: SmtpClient smtpClient = new SmtpClient();
Line 69: MailMessage message = new MailMessage();
Line 70:
Line 71: //try

Source File: c:\inetpub\vhosts\\httpdocs\ContactUs.aspx.cs Line: 69

Stack Trace:

[FormatException: The specified string is not in the form required for an e-mail address.]
System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index) +1252418
System.Net.Mail.MailAddressParser.ParseAddress(String data) +23
System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding) +245
System.Net.Mail.MailMessage..ctor() +133
Feedback.Button1_Click(Object sender, EventArgs e) in c:\inetpub\vhosts\\httpdocs\ContactUs.aspx.cs:69
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

Make sure the email id you are sending the email to has been entered correctly.
Share this answer
Try THIS[^]

It's in your <><mailsettings><smtp> element in your web.config. Make sure the "from" attribute of the <smtp> element contains a valid email address.

hope it helps :)
Share this answer
Member 7976636 10-Oct-11 3:27am    
i have a big doubte ?what we need to give as host="smtpserver1" port="25" userName="username" password="secret" in my control panel?i need to know what name we want to give to host="",etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900