mail failed

  • Thread starter Thread starter Zeeway
  • Start date Start date
Z

Zeeway

hi,everybody
I use dotnet 2005 and c sharp to deliever a mail to a certain mail
address,but it failed with messages such as "invalid parameter,the server
response: decode failed". My codes is listed belowed:
try
{
MailMessage mailObj = new MailMessage();
mailObj.To.Add("(e-mail address removed)");
mailObj.From = new MailAddress([email protected]);

mailObj.Subject = "Óʼþ²âÊÔ";
mailObj.Body = "ºÍѶÓʼþ½ÓÊÕ²âÊԳɹ¦! ";

mailObj.IsBodyHtml = true;
mailObj.Priority = MailPriority.High;
mailObj.BodyEncoding = System.Text.Encoding.UTF8;

System.Net.Mail.SmtpClient client = new
System.Net.Mail.SmtpClient("smtp.21cn.com");
client.UseDefaultCredentials = false;

client.Credentials = new
System.Net.NetworkCredential("(e-mail address removed)",
this.tb_mailUserPassword.Text);
client.DeliveryMethod = SmtpDeliveryMethod.Network;

client.Send(mailObj);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}

(e-mail address removed) is a correct account of mail.21cn.com,Could anyone
help me?


Crespo
2006-06-30
 
perhaps it is because you told hotmail that the mail message was an HTML
message in UTF-8 yet your message body is clearly not HTML or UTF-8.

That would explain what it failed to decode the message...

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Thanks for your answer. But following your advice,I set the
mailObj.IsBodyHtml as false and mailObj.BodyEncoding as
System.Text.Encoding.ASCII,it still failed with the same error message,Could
you further explain for me?

Crespo


"Nick Malik [Microsoft]" <[email protected]> дÈëÏûÏ¢
perhaps it is because you told hotmail that the mail message was an HTML
message in UTF-8 yet your message body is clearly not HTML or UTF-8.

That would explain what it failed to decode the message...

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Thanks for your attention. In fact,my first code works well when I specify
some certain smtp servers,but doesn't work well over others which are even
correct smtp servers. Thank you very much anyway.


Crespo
 
Perhaps my newsreader is just playing tricks on me. On my screen, the
following lines contain non-ASCII characters:
mailObj.Subject = "Óʼþ²âÊÔ";
mailObj.Body = "ºÍѶÓʼþ½ÓÊÕ²âÊԳɹ¦! ";

So, setting the coding to ASCII doesn't help. To be honest, I made a
mistake when I said that it was not UTF-8. It does appear to be UTF-8. It
does not appear to be HTML, though.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Thank you for your kind advice. I have found the reason. In fact ,my codes
work well over some SMTP Server,but not over others. This is just because
some SMTP Server needs more authorization than common ones.Thank you anyway.

Best Regards

Crespo
 
Zeeway said:
Thank you for your kind advice. I have found the reason. In fact ,my codes
work well over some SMTP Server,but not over others. This is just because
some SMTP Server needs more authorization than common ones.Thank you
anyway.

Best Regards

Crespo

Sorry I couldn't be more help. I assume you have discovered how to send
authentication information to the SMTP server, since you did not ask for
further information.

Good Luck,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

mail failed 3
sending mails 4
sending mails 1
question about sending email 7

Back
Top