用.net自带的发邮件,怎样修改发件人名称??
我写了下面的代码,想用QQ邮箱发邮件,可以成功发邮件了
但是发过去时,发件人显示 "736230838 ",感觉很难看
请问怎么让别人收到的邮件的发件人写我的名字??
public void MySendMail(string mailto,string mailsubject,string mailbody)
{
MailMessage mm = new MailMessage();
mm.To = mailto;
mm.From = "736230838@qq.com ";
mm.Subject = mailsubject;
mm.Body = mailbody;
mm.BodyFormat = MailFormat.Html;
mm.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 ");
mm.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ", "736230838 ");
mm.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", "123456 ");
SmtpMail.SmtpServer = "smtp.qq.com ";
SmtpMail.Send(mm);
}
------解决方案--------------------你用的是1.1么?
2.0中可以这样
msg.From = new MailAddress( "nhibernate@qq.com ", "nhibernate now ");
------解决方案--------------------赋值是字符串的话可以用
mm.From = "\ "nhibernate now\ " <nhibernate@qq.com> ";
mm.Sender = " <nhibernate@qq.com> ";