Vasyl Senko
Vasyl Senko

Reputation: 1809

Display name issue when using System.Web.Mail.MailMessage

Problem in using System.Web.Mail.MailMessage, in received message the display name is "????????".

System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.BodyEncoding = System.Text.Encoding.UTF8;
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.server");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", AccountEmail);
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", AccountPassword);
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
myMail.From = string.Format("\"{0}\"<{1}>", "Unicode text", AccountEmail);

myMail.To = to;
myMail.Subject = title;
myMail.BodyFormat = System.Web.Mail.MailFormat.Html;
myMail.Body = messageStr;

System.Web.Mail.SmtpMail.SmtpServer = "smtp.server:465";
System.Web.Mail.SmtpMail.Send(myMail);

Upvotes: 0

Views: 925

Answers (1)

wbennett
wbennett

Reputation: 2563

Consider using System.Net.Mail instead.

Note: This API is now obsolete. Provides properties and methods for constructing an e-mail message. Recommended alternative: System.Net.Mail.

http://msdn.microsoft.com/en-us/library/system.web.mail.mailmessage(v=vs.110).aspx

Upvotes: 1

Related Questions