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
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
You were online. Sorry.
It is more simple. There is simpliest string, like "123". Same error
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
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 mailAsNew 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 smtpAsNew 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 ExAs Exception
response.write("Email send failed error code is... " & Ex.Message)EndTry
EndSub
no success, same error
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
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?
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>
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 comments:
Post a Comment