我试图发送电子邮件,并设置了来自电子邮件地址的显示名称。但是,当我在客户端收到电子邮件(例如gmail)时。我没有显示名称,而是看到不带域的电子邮件地址,表示从“ FromEmail@abc.com”电子邮件中接收到的邮件,然后显示给我,表明我从“ FromEmail”接收了电子邮件。
这是我的代码
MailMessage mail = new MailMessage();
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.HeadersEncoding = System.Text.Encoding.UTF8;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Priority = System.Net.Mail.MailPriority.High;
mail.IsBodyHtml = true;
mail.From = new MailAddress("FromEmail@abc.com","Automate");
mail.To.Add(new MailAddress("ToEmail@abc.com"));
mail.Subject = "This is test email";
mail.Body = "This is test mail.";
SmtpClient client = new SmtpClient("smtp.office365.com");
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("senderEmail@abc.com", "*****");
client.Send(mail);