Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I need to send an email in asp.net but I need sender appears like "MySiteName" without [email protected].

like image 838
MeqDotNet Avatar asked Apr 29 '10 13:04

MeqDotNet


People also ask

Which one is the correct option to send a mail message in asp net?

For sending email we need a SMTP Server, so in ASP.Net we have the SmtpClient class, using that class object we set its properties for the SMTP settings. SmtpClient client = newSmtpClient("smtp.gmail.com", 587);


2 Answers

Like this:

using(MailMessage message = new MailMessage(         new MailAddress("[email protected]", "Your Name"),         new MailAddress("[email protected]", "Their Name")     )) {     message.Subject = ...;     message.Body = ...;      new SmtpClient().Send(message); } 

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

like image 152
SLaks Avatar answered Oct 26 '22 23:10

SLaks


you could try something like this

MailAddress from = new MailAddress("[email protected]", "MySiteName"); 

More info here

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

like image 30
Bala R Avatar answered Oct 27 '22 00:10

Bala R