No Opinions...just code

Sending Mail

    1 SmtpClient mailClient;
    2 String[] recipients;
    3 
    4 private void SendMail(MailAccount theAcct, MailMessage theMsg)
    5 {
    6     MailAccount acct = theAcct;
    7 
    8     mailClient = new SmtpClient();
    9     mailClient.Host = acct.MailOut;
   10     mailClient.Port = acct.MailOutPort;
   11     mailClient.Credentials = new NetworkCredential(acct.Username, acct.Password);
   12 
   13     foreach (String s in recipients)
   14     {
   15         try
   16         {
   17             theMsg.To.Add(new MailAddress(s));
   18         }
   19         catch (FormatException e)
   20         {
   21         }
   22         mailClient.Send(theMsg);
   23     }
   24 }

0 comments: