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:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...