Send email from ASP.NET

using System.Net;
using System.Net.Mail;

MailMessage o = new MailMessage("from", "to", "subject", "body"); 
NetworkCredential netCred = new NetworkCredential("from", "from mail password");
SmtpClient smtpobj = new SmtpClient("your smtp server", 25);
// smtpobj.EnableSsl = true;
smtpobj.Credentials = netCred;

//========another example
SmtpClient smtpClient = new SmtpClient("", 25);

smtpClient.Credentials = new System.Net.NetworkCredential("", "myPassword");
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
MailMessage mail = new MailMessage();

//Setting From , To and CC
mail.From = new MailAddress("info@MyWebsiteDomainName", "MyWeb Site");
mail.To.Add(new MailAddress("info@MyWebsiteDomainName"));
mail.CC.Add(new MailAddress(""));


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s