Reputation: 39443
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?
Upvotes: 24
Views: 5781
Reputation: 3
<system.net>
<mailSettings>
<smtp from ="XYZ<[email protected]>">
<network host="smtp.gmail.com" port="25" userName="[email protected]" password="******" enableSsl="true"/>
</smtp>
</mailSettings>
</system.net>
1)Please Use these setting in app.config file
Upvotes: -3
Reputation: 2220
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=""John Smith" <[email protected]>">
Upvotes: 54