Sending emails in asp.net with specific name instead of sender email Sending emails in asp.net with specific name instead of sender email asp.net asp.net

Sending emails in asp.net with specific name instead of sender email


Like this:

using(MailMessage message = new MailMessage(        new MailAddress("You@Domain.com", "Your Name"),        new MailAddress("Recipient@OtherDomain.com", "Their Name")    )) {    message.Subject = ...;    message.Body = ...;    new SmtpClient().Send(message);}

You will need to enter the SmtpClient's connection settings in Web.config


you could try something like this

MailAddress from = new MailAddress("info@mysitename.com", "MySiteName");

More info here

http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.aspx


There are 2 ways, if you are using MailAddress you can use the constructor overload to input the display name, or simply format the recipient address as MySiteName <info@mysitename>

For a downloadable example see here