The specified string is not in the format required for an email address

October 18, 2012

I recently had the following exception fire on a site I manage:

The specified string is not in the format required for an email addres
System.FormatException
at: System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName);

My immediate thought was to check the email address – Yup, valid!

The actual fix was to add the following to my web.config – Unfrotnatley I have no idea why this is required, as I was specifiying a from address within the C#. The email sent even came from the address specified in the C#, not the one I specified in the web.config.

<system.net>
    <mailSettings>
        <smtp from=”user@domain.com” />
    </mailSettings>
</system.net>

Advertisements

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: