System.FormatException: The specified e-mail address is currently not supported

StackOverflow https://stackoverflow.com/questions/15081373

  •  11-03-2022
  •  | 
  •  

سؤال

I receive this error when my code executes from my Windows 2003 server, however from my Windows 7 dev machine the mail process works flawlessly every time. Project is configured for 2.0 framework. Is there a missing component that is needed on the server??

Error Detail.

[FormatException: The specified e-mail address is currently not supported.]
   System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName) +1138987
   System.Net.Mail.MailAddress.ParseValue(String address) +240
   System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding) +85
   System.Net.Mail.MailAddress..ctor(String address) +8
   BizHelp.WebForm1.btnSendEmail_Click(Object sender, EventArgs e) +117
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   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) +1565

Web.Config details (this is non-standard format for GoDaddy, but I must run my code on local network, hence I cannot use their relay server - and this works on my Windows 7 box)

<mailSettings>
      <smtp>
        <network host="smtpout.secureserver.net" defaultCredentials="false"
                 userName="xxxxx@sendtome.us" password="xxxxx"  enableSsl="false" port="80"/>
      </smtp>
</mailSettings>

VB Code:

Imports System.Net.Mail

Dim mm As New MailMessage(lblEmail.Text, "2manybooks@sentome.us")
mm.Subject = "Welcome to xxxx"
mm.IsBodyHtml = True

mm.Body = lblMail.Text.ToString
Dim smtp As New SmtpClient
smtp.Send(mm)

Note: lblEmail.text is a field containing a standard email address; that field is loaded from a database.

Any thoughts or suggestions? Thanks!!

هل كانت مفيدة؟

المحلول

The most likely thing to be happening is that one or more of the values for your ToAddress is just not a valid email address. I'm thinking it's the ToAddress because your FromAddress is hard-coded and looks valid.

Try putting a Debug.WriteLine("\"" + lblEmail.Text + "\"") statement right before you attempt to create the ToAddress. (The quotation marks are there in case the value is empty.) After the crash, inspect the Output window, Debug pane. Is there anything weird there? Anything that doesn't look like a valid address?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top