Advertisements

The specified string is not in the form required for an e-mail address

Find this post interesting? Do you like interesting things? Maybe you would like my invention, a connectible candle called a WickBrick!

Get one here http://wickbrick.etsy.com/

WickBrick

Need to create a MailAddress….. grrr

http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.aspx

And if you want to convert from text inside of a textbox control to a MailAddress you need to use the .text property  i.e.

Dim fromUser As New MailAddress(from_txt.Text)

Advertisements

4 Responses

  1. The specified string is not in the form required for an e-mail address.
    code:
    public static void SendMail(string from, string to, string subject, string body)
    {
    // Configure mail client (may need additional
    // code for authenticated SMTP servers)
    SmtpClient mailClient = new SmtpClient(BalloonShopConfiguration.MailServer);
    // Create the mail message
    MailMessage mailMessage = new MailMessage(from, to, subject, body);
    // Send mail
    mailClient.Send(mailMessage);
    }
    public static void SendErrorLogEmail(Exception ex)
    {
    string from = “BalloonShop Error Report”;
    string to = BalloonShopConfiguration.ErrorLogEmail;
    string subject = “BalloonShop Error Generated at ” + DateTime.Now.ToShortDateString();
    string body = ex.Message + “\n\n” + “Stack trace:\n” + ex.StackTrace.ToString();
    SendMail(from, to, subject, body);
    }

  2. please help for the above error

  3. After reading through the article, I feel that I need more information on the topic. Can you suggest some resources ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: