Skip to content

Instantly share code, notes, and snippets.

@kashwaa
Created June 16, 2014 01:05
Show Gist options
  • Save kashwaa/a02a951721e9e9652465 to your computer and use it in GitHub Desktop.
Save kashwaa/a02a951721e9e9652465 to your computer and use it in GitHub Desktop.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Net.Mail;
using System.Collections.Generic;
using System.IO;
using System.Text;
public class EmailSender
{
public static SmtpClient GetClient()
{
SmtpClient scg = new SmtpClient("smtp.gmail.com", 25);
scg.UseDefaultCredentials = false;
scg.Credentials = new System.Net.NetworkCredential("EMAIL", "PASSWORD");
scg.EnableSsl = true;
return scg;
}
public static void sendmail(string subject, string body, params string[] to)
{
MailMessage mes = new MailMessage();
mes.From = new MailAddress("EMAIL");
foreach (var item in to)
{
mes.To.Add(item);
}
mes.Subject = subject;
mes.Body = body;
mes.IsBodyHtml = true;
SmtpClient sc = GetClient();
sc.Send(mes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment