22
Email Via Gmail in C#
Using this function we can send email from Gmail from C# application.
public bool Gmail_Mailer(string GmailId, string Password, string To, string Subject, string Body, System.Web.Mail.MailFormat Format, string AttachmentPath)
{
try
{
System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.Fields.Add(”http://schemas.microsoft.com/cdo/configuration/smtpserver”,”smtp.gmail.com”);
myMail.Fields.Add(”http://schemas.microsoft.com/cdo/configuration/smtpserverport”,”465″);
myMail.Fields.Add(”http://schemas.microsoft.com/cdo/configuration/sendusing”,”2″);
//sendusing: cdoSendUsingPort, value 2, for sending the message using
//the network.
//smtpauthenticate: Specifies the mechanism used when authenticating
//to an SMTP
//service over the network. Possible values are:
//- cdoAnonymous, [...]