To send Email using Gmail Account asp.net

public static bool SendEMail(string to, string from, string subject, string body, string attachments)
        MailMessage mail = new MailMessage();

        //set the addresses
        mail.From = new MailAddress(from);

        //set the content
        mail.Subject = subject;
        mail.Body = body;
        mail.IsBodyHtml = true;
        if (attachments.Length > 0)
            if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(attachments.Trim())))
                mail.Attachments.Add(new     Attachment(HttpContext.Current.Server.MapPath(attachments.Trim())));
        //send the message
        SmtpClient smtp = new SmtpClient();

        //to authenticate we set the username and password properites on the SmtpClient

        SmtpClient client = new SmtpClient("smtp.gmail.com");
        client.Port = 587;
        client.EnableSsl = true;
        NetworkCredential credential = new NetworkCredential("InfoA2Z@gmail.com", "xxxxxxxx");
        client.UseDefaultCredentials = false;
        client.Credentials = credential;
        return true;

Related Alrticles

FREE!!! Registration