我有以下代码。现在我不想将我的电子邮件地址显示为发件人地址,而是我需要一个友好的名称。有没有办法实现这个目标?
MailMessage mail = new MailMessage();
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Credentials = new System.Net.NetworkCredential("userName", "password");
smtpServer.Port = 587;
mail.From = new MailAddress("myemail@gmail.com");
mail.To.Add("recepient@gmail.com");
mail.Subject = "Password recovery";
mail.Body = "Recovering the password";
smtpServer.Send(mail);
我可以更改邮件吗?
答案 0 :(得分:3)
请尝试以下。
mail.From = new MailAddress("myemail@gmail.com","Your display name");
OR
using(MailMessage message = new MailMesage(
new MailAddress("myemail@gmail.com", "Your display Name"),
));