Wednesday, September 15, 2010

How to send an email using Gmail in Asp.net and C#

string toAddress = "you@yahoo.com";
string fromAddress = "me@gmail.com";
string password = "myPassword";
MailMessage message = new MailMessage(fromAddress, toAddress);
MailAddressCollection to = new MailAddressCollection();
to.Add(new MailAddress(toAddress));
message.Subject = "RE: Feedback";
message.Body = "A Test Eamil <br /> by using Gmail <hr /> Thanks";
message.IsBodyHtml = true;
SmtpClient smtpSender = new SmtpClient();
smtpSender.Port = 587;  
smtpSender.Host = "smtp.gmail.com";
smtpSender.EnableSsl = true;
smtpSender.Credentials = new System.Net.NetworkCredential(fromAddress, password);
smtpSender.Send(message);

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...