Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I setup a friendly email name in the MailSetting section of web.config?

Currently I have:

<system.net>
    <mailSettings>
    <smtp from="[email protected]">
        <network 
             host="localhost" 
             port="25"
             />
      </smtp>
    </mailSettings>
  </system.net>

How can I change it so the email is sent with a name and not the email address only?

like image 685
Eduardo Molteni Avatar asked Oct 31 '08 01:10

Eduardo Molteni


1 Answers

Well, in code you need to put the sender's name in quotes, followed by the e-mail address.

new SmtpClient(...).Send("\"John Smith\" [email protected]", ...);

And...it looks like you can encode it into the attribute too...

<smtp from="&quot;John Smith&quot; &lt;[email protected]&gt;">
like image 183
Ty. Avatar answered Nov 17 '22 15:11

Ty.