Ads 468x60px

Pages

Blogroll

Monday, April 9, 2012

Send Mail via Gmail account



Add these two namespaces at the top of the page first.

using System.Net.Mail;


using System.Net;

Then add the below function on your page and pass the required parameters.
/// <summary>
    /// 
    /// Send Mail from your application via gmail account
    /// 
    /// Your gmail id/// your gmail password/// Mail id to whom you want to send mail/// Suject of the mail/// Body of the mailpublic void SendMail(string sourceGmailMailID,string gmailPassword, string destinatioMailID,string subject, string body)
    {
        var client = new SmtpClient("smtp.gmail.com", 587)
        {
            Credentials = new NetworkCredential(sourceGmailMailID, gmailPassword),
            EnableSsl = true
        };
        client.Send(sourceGmailMailID, destinatioMailID, subject, body);
    }
http://stackoverflow.com/questions/1644201/how-can-i-display-code-better-on-my-blogger-blog
To send the mail to multiple receptionists pass the destinatioMailID parameter with comma (,) separated source mail ids like "abc@gmail,xyz.yahoo@com" etc.

0 comments:

Post a Comment