来自:http://outofmemory.cn/code-snippet/1638/c-fayoujian-display-youhao-fajianren-method
发件人可以设置为\Webtips Emailer\ admin@webtips.co.in格式,这样在收件人看到的邮件就可以看Webtips Emailer的友好用户名了。
代码如下:
//Creating new mail message
System.Web.Mail.MailMessage MyMail = new System.Web.Mail.MailMessage();
//Display Name can be sent using following format
//\<<Friendly Display Name>>\ <mailaddress>"
MyMail.From = @"\Webtips Emailer\ <admin@webtips.co.in>";
//To Address
MyMail.To = "webtips.co.in@gmail.com";
// BCC Address
MyMail.Bcc = "somename@someserver.com";
//Mail Subject
MyMail.Subject = "Subject Of the mail";
//Body of the mail
MyMail.Body = "<html><body>test mail message</body></html>";
MyMail.BodyFormat = System.Web.Mail.MailFormat.Html;
//SMTP Server name or IP from which mail to be sent
System.Web.Mail.SmtpMail.SmtpServer = "smtp.someserver.com";
//Sending Mail
System.Web.Mail.SmtpMail.Send(MyMail);