News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Send Mail With Gmail

Started by VelMurugan, Dec 18, 2008, 06:18 AM

Previous topic - Next topic

VelMurugan

Send Mail With Gmail

using System;
using System.Collections.Generic;
using System.Text;

namespace PAB.SEO
{
public static class GmailSender
{
public static void SendGmail(string userName, string password, string mailFrom, string mailTo, string commaDelimCCs, string subject, string message, bool isBodyHtml)
{
System.Net.Mail.MailMessage msg = new
System.Net.Mail.MailMessage(mailFrom, mailTo,
subject, message);
msg.IsBodyHtml = isBodyHtml;
if(commaDelimCCs!="")
msg.CC.Add(commaDelimCCs );
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential(userName, password);
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = cred;
mailClient.Send(msg);
}
}
}