System.Net.Mail.SmtpClient.Send() Error: An invalid character was found in the mail header

hi all!

please help!

I wanted to make an automatic email when I create user by CreateUserWizard. So I configured SMTP, then in properties of the wizard indicated textfile for message and wrote simple subject "registration"

 

but I have an exception (like in subj).

I even tried to set the subject in event handler for "emailsending" event. Same exception. 

 

What is wrong? How could I fix it? 

 

Here us some info from stack:

[FormatException:An invalid character was found in the mail header.] System.Net.BufferBuilder.Append(String value, Int32 offset, Int32 count) +915954 System.Net.Mail.EHelloCommand.PrepareCommand(SmtpConnection conn, String domain) +106 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +835 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316 System.Net.Mail.SmtpClient.GetConnection() +42 System.Net.Mail.SmtpClient.Send(MailMessage message) +1485

 

[SmtpException: Email send failure.] System.Net.Mail.SmtpClient.Send(MailMessage message) +2074 System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +341 System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +571 System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105 System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453 System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149 System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +171 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 

0
Vorlosha
10/13/2007 8:51:43 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

10 Replies
7468 Views

Similar Articles

[PageSpeed] 13

Hi  there, can i just ask why you choose me? as for your problem, it looks like there is an invalid character in the mail header, so either there is nothing in it or something there shouldnt be, try taking a few steps back, if your attaching a text file just simply put a few words coded in, and if your header is dynamic try making it hard coded


Jeremy Huson
Senior Network Engineer
Carden Computers - PC Repair Brighton
0
jezh
10/13/2007 8:08:02 PM

You were online. Sorry.

 It is more simple. There is simpliest string, like "123". Same error
 

0
Vorlosha
10/13/2007 8:11:02 PM

hey no worries, well try a string like abc, also make sure no fields are not left blank. What usually helps me is take a 10 min break, clear you head have a coffee and come back look through your code as if you have never seen it before. something may catch. Im not the worlds best .neter but i usually find if there is a problem its often by taking things back to basic it helps


Jeremy Huson
Senior Network Engineer
Carden Computers - PC Repair Brighton
0
jezh
10/13/2007 8:55:43 PM

If your still not having any success you could try the code below and see if it makes any difference.

Regards

Martijn 

 

Sub
mailout() Dim mail As New Net.Mail.MailMessage()

'set the addresses

mail.To.Add("recipient@whereever.com")

mail.From = New Net.Mail.MailAddress("sender@wherever.com"))

'set the content

mail.Subject = "Email Subject line"

mail.Body = "The main body of the email message"

'send the message

Dim smtp As New Net.Mail.SmtpClient("smtp.whereever.com")

'to authenticate we set the username and password properites on the SmtpClient

smtp.Credentials = New Net.NetworkCredential("smtp-accountname e.g. sender@wherever.com", "smtp-account-password")

Try

smtp.Send(mail)

response.write(
"Email sent successfully")

Catch Ex As Exception

response.write("Email send failed error code is.... " & Ex.Message)

End Try

End Sub

-1
MartijnG
10/14/2007 1:04:43 PM

no success, same error 

0
Vorlosha
10/14/2007 1:22:33 PM

I cant come up with any conclusions from your stack trace.

The code I gave you I copied out of an application I wrote there was something I had missed and should have cleaned up in the following line

mail.From = New Net.Mail.MailAddress(Session(sender@wherever.com))

 It should be this (no reference to any session variable)

 mail.From = New Net.Mail.MailAddress(sender@wherever.com)

 

The only other question is does your recipient or sender email address have any unusual charactors or attempt to have a space in it? Any thing like that could cause a problem. Try the same code with different email addresses and different content.

Sorry no other suggestions

Martijn

0
MartijnG
10/14/2007 1:44:42 PM

May be this piece of code will help:

 

<system.net>
<mailSettings>
<smtp from="evdokp@pochta.ru">
<network host="mail.pochta.ru" password="[мой пароль]" userName="evdokp@pochta.ru" />
</smtp>
</mailSettings>
</system.net>

 

this is how ASP.NET build-it configuration tool edits web.config

 Well, my additional question is: where does the tool sets port value?
 

0
Vorlosha
10/14/2007 3:29:31 PM

ok, my sugesstion is to take remove the brackets from the password and to use a password with standard English character set without and spaces.

Be sure to update the password on the mail server too.

Good luck

<system.net>
<mailSettings>
<smtp from="evdokp@pochta.ru">
<network host="mail.pochta.ru" password="myPassword" userName="evdokp@pochta.ru" />
</smtp>
</mailSettings>
</system.net>

0
MartijnG
10/14/2007 3:35:52 PM

it is not that easy.

these brackets are there just because I hide my password. It was like you say "myPassword" 

 

Do you know where port is defined in web.config? 

0
Vorlosha
10/14/2007 4:06:20 PM

Hello

I Have the same problem but I have new data for you to analyze.

 The problem wasn't there until today.

Until today I developed my webside on Windows XP machine, Today I moved it to a new machine of Windows Vista Ultimate and the same Code on vista produce an error (same as you mentioned)

Need Help too.

 

 

0
trackisimo
10/14/2008 5:07:03 PM
Reply:

Similar Artilces:

System.Net.Mail.SmtpClient.Send() Error: An invalid character was found in the mail header #2
Hello  I get This error when trying to send mailMessage. The problem wasn't there until today. Until today I developed my webside on Windows XP machine, Today I moved it to a new machine of Windows Vista Ultimate and the same Code on vista produce an error (same as you mentioned) Need Help.   Thanks, Hi,What character set are you using? Try setting the encoding to Encoding.UTF8;   Narmatha Balasundaramhttp://reflexangle.blogspot.com I tried to set the subject and body encoding to UTF8 with no luck.  The thing is that the code works fine on Windows ...

Why do Sending SMTP Authenticated E-mail succeed using SmtpMail.Send() function but fail using SmtpClient.send() function ? Bugs in System.Net.Mail.SmtpClient when send a Authenticated E-mail?
I click btnOK button, the email can send OK, but click btnFail button,  the following error is displayed! why ? you can test the section code. The SMTP, username, password are valid!  Many thanks! "Syntax error, command unrecognized. The server response was: authentication failed,decode user password error" I have tested some other SMTP, somes is OK. I think there are some bugs with System.Net.Mail.SmtpClient when send a Authenticated E-mail with some SMTP!   //------------------------------------------.ASPX Code----------------------------------------...

Sending Email through System.Net.Mail is generating errors "Failure Sending mail
hi Sending Email through System.Web.Mail is working fine but System.Net.Mail is generating errors "Failure Sending mail  i treid in all possible ways but did't  pls help in giving a solution thanks & Regards vittal Maybe you can show us some code and post the exact error mesg as well (by looking at the value in ex.tostring)?My HomePage - www.findingsteve.net"It is more blessed to give than to receive." Acts 20: 35 (NIV, Bible)Progress - "Never discourage anyone...who continually makes progress, no matter how slow." Plato System.Web.Ma...

Error handling sending mail (system.net.mail)
 Hi I did an aplication for send membership comunications and i want make a simple upgrade. I have a while for sent the messages to every recipients but i want in each recipient get if the mail has sent or failed, this is for sum that on a cell for the message but i dont know how get if the message go or failed?Im using VB. Somebody can help me on that?  You can't know for sure if the message was delivered or not. The only option would be to read any returned messages from the mail server. Website Design Darlington - http://mdssolutions.co.ukhttp://lesstha...

.net 2 beta 2 - System.Net.Mail
Hi guysI'm using the System.Net.Mail namespace in .net version 2, beta 2, to send out some HTML formatted e-mails.However, for some reason when the e-mail are sent out some of the full stops from the e-mail are removed.For example, part of the e-mail contains this code<img src="http://www.avonandsomerset.police.uk/images/grey_box_bottom.gif" alt="">But this is what the code is like when the e-mail source code is viewed<img src="http://www.avonandsomerset.police.uk/images/grey_box_bottomgif" alt="">Is this a known bug in beta 2? If so, where can I view a list of known bugs an...

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add("admin1@yoursite.com"); message.Subject = "Feedback"; message.CC.Add("admin1@yoursite.com"); message.CC.Add("admin2@yoursite.com"); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

How to send e-mail to invalid address using System.Net.Mail.MailMessage
Hi all,i need create MailMessage with invalid address. It is posible? I need send mail to smtp server with MailMessage.To = "[FAX: ...fax number.....]". Thanks all for any help! p.s.: sorry for my english.  It can't be an invalid email address, but if you run a fax server the email address in the fax server syntax should work fine. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue....

system.net.mail not sending out mail
I recently upgraded from a 2.0 framework to 3.5 using c#.  When I upgraded, I needed to change the way I was using MailMessage.  But now for some reason it doesn't work.  Am I missing something?Below is my code:using System.net.Mail; MailMessage msg = new MailMessage();msg.To.Add(toList);msg.CC.Add(ccList = null ? "" : ccList);msg.From = new MailAddress(fromList);msg.Subject = subject;msg.Body = body;msg.IsBodyHTML = true; SmtpClient smtp = new SmtpClient(smtpServer);smtp.Send(msg); I'm passing all the value from my web.config file inside AppSettings.What ...

About: how can i send a MIME(Text und Html Format) Mail by System.Net.Mail und .Net 2.0
Helle to all, I hope that someone can help me. I need to implement a programm to send newsletters. The newsletter Format can be Html, Text and MIME(Html and Text). when using CDONTS library man can set MailFormat = MIME. But i use System.Net.Mail and there are only text or html Format. Can someone tell me how can i use System.Net.Mail to send a MIME Mail? Thanks Best Regards Pinsha perhaps this link can help:  http://systemnetmail.com/faq/3.1.3.aspxIn this world there are 10 types of people, those that know binary and those who don't....

What additional advantage we get through System.net.mail over the old system.web.mail?
What additional advantage we get through System.net.mail over the old system.web.mail?Is it needed to configure the smtp server? Plz tell me the steps to develop the email sending facility in our applicationSwati Jain Take a look at www.systemnetmail.com.JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue....

get mail using System.Net.Mail
How can i get Email usign System.Net.Mail ?? Hello poloxy  ,the System.Net.Mail used only for sending emails and not to receive them.Read the full documentation at  MSDN Library http://technet.microsoft.com/en-us/library/system.net.mail.aspx  Hosam Kamel Remember to click on Mark as answer on the post that helped you SO how can I receive mail ? Try one of these pop3 librarieshttp://www.codeproject.com/info/search.aspx?artkw=pop3  Hosam Kamel Remember to click on Mark as answer on the post that helped you HI,   if you want to send email by using System....

Sending mails with Net.Mail: no Email, No Error
hi,i'm using the system.net.Mail namespace to send an email from my application. when i send, the application does not fire any exception, neither does it send the email to my account.below is the code i'm using  Dim mmailMessage As New Net.Mail.MailMessage Dim mFrom As New Net.Mail.MailAddress(mailFrom) mmailMessage.From = mFrom Dim ll As String = "myname@ourmail.com" mmailMessage.To.Add(ll) mmailMessage.Subject = "Talk Concerns" mmailMessage.Body = "Testing Concerns One Two" Dim sm As...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

System.Net.Mail.SmtpException: Failure sending mail
Hi, I written the code in .aspx.cs mail send button click event  and i import name space using System.Net.Mail;  String strSubject = "Subject of the mail”;String strMailbody="Body of the mai"; Try{MailMessage Message = new MailMessage();Message.To.Add(new MailAddress("xxxx@domain.com"));Message.From = new MailAddress("xxxx@domain.com"); Message.CC.Add(new MailAddress("xxxx@domain.com"));Message.CC.Add(new MailAddress("xxxx@domain.com")); Message.Subject = strClaimSubject;Message.Body = strClaimMailbody;Messag...

Web resources about - System.Net.Mail.SmtpClient.Send() Error: An invalid character was found in the mail header - asp.net.getting-started

Full Featured Email using powershell
... this is a fairly simple, however not quite so well explained – at least that i could find – process. Let us start simply, with the basic SMTPClient ...

Code - eventmachine/eventmachine - Code Climate
Get these same great results for any of your GitHub Repos. 100% free for Open Source, forever Code Climate Login Sign Up with GitHub Pricing ...

Setting of Google Gmail (IMAP, SMTP and POP3) - Coders Grid
Coders Grid your best development resources collections site Menu Skip to content Resource web development design stuffs guideline coding mobile ...

jQuery Contact Tabs Plugin « Design Chemical – jQuery, Wordpress, Tutorials & Plugins
jQuery Contact Tabs Plugin - Create slide out or static contact tabs with customised forms

Sample C# code for SMTP Email - EasySMTP
Send C# email via SMTP with this C# sample code from Easy-SMTP

Ginktage - A technology and Programming Blog on .NET , Delphi , SQL Server and Microsoft related technologies ...
... , Windows Mobile , Android , iOS development using If you need to send emails via SMTP programmatically using C# , you can use the the SmtpClient ...

Private Sub emailTeacher() Try Dim Server As New SmtpClie - Pastebin.com
PASTEBIN - #1 paste tool since 2002 create new paste tools api archive faq PASTEBIN create new paste trending pastes sign up login my alerts ...

CodeSOD: Patterned After Success
... Which is why Andres was getting null reference exceptions when trying to get an instance from this “singleton”. public class SingletonSmtpClient ...

Simple TLS/SSL SMTP client for Qt5 - Rastro-Mania - Coding and Engineering
Projects and tutorials in computer programming and electronics engineering

IIS7 - post #23 - Vista and SMTP server. Where is it?
Where is my SMTP server on Vista? I'm not sure why more developers haven't asked this question. Simple, it is not included - http://blogs.i ...

Resources last updated: 1/2/2016 6:17:21 AM