Created
June 16, 2014 01:05
-
-
Save kashwaa/a02a951721e9e9652465 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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