Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailMessage setting the Senders Name

Tags:

c#

Is it possible to set the sender name on a MailMessage object? I tried setting it from MailAddress, but the DisplayName property seems to be read only.

I tried "My Name " as the sender and don't seem to work either.

like image 921
James Jeffery Avatar asked Feb 09 '10 19:02

James Jeffery


People also ask

What is an email display name?

Overview. When you send an email, the display name that appears next to your email address is called the Sender info. In Front, Sender info is tied to the signature that you use when sending an email. It can be changed in your signature settings at any time.


2 Answers

MailMessage mail = new MailMessage(); mail.From = new MailAddress("[email protected]", "Bob Jones" ); 
like image 182
Ta01 Avatar answered Sep 25 '22 02:09

Ta01


You do not need to use the MailAddress class.

You can let the runtime parse your string.

var message = new MailMessage(     "My Name [email protected]",      "Recipient One [email protected],Recipient Two [email protected]",     "Subject",     "Body"); 
like image 32
loraderon Avatar answered Sep 24 '22 02:09

loraderon