Is it possible to set the sender name on a MailMessage
object? I tried setting it from MailAddress
, but the DisplayName
property seems
From the MSDN http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx
MailMessage message = new MailMessage(
"jane@contoso.com",
"ben@contoso.com",
"Quarterly data report.",
"See the attached spreadsheet.");
You do not need to use the MailAddress class.
You can let the runtime parse your string.
var message = new MailMessage(
"My Name my@name.com",
"Recipient One recipient@one.com,Recipient Two recipient@two.com",
"Subject",
"Body");
MailMessage mail = new MailMessage();
mail.From = new MailAddress("nerfDeathKnights@mycompany.com", "Bob Jones" );