public void Send(IJTXNotification ipNotification) { try { LogMessage(5, 1000, "SendSecureSMTP: Setting up to send a secure notification to " + m_strSMTPServer + ", on Port " + m_strSMTPPort); SmtpClient mailClient = new SmtpClient(m_strSMTPServer); //////////////////////////////////////// // NOTE: This is for sample purposes only... Should be an encrypted password that must be descrypted first //////////////////////////////////////// ICredentialsByHost ipCredentials = new NetworkCredential(m_strSMTPUser, m_strSMTPPassword); mailClient.EnableSsl = true; mailClient.Credentials = ipCredentials; mailClient.DeliveryMethod = SmtpDeliveryMethod.Network; mailClient.Host = m_strSMTPServer; int smtpPort = 25; if (Int32.TryParse(m_strSMTPPort, out smtpPort) == false) { smtpPort = 25; } mailClient.Port = smtpPort; mailClient.Timeout = 10000; LogMessage(5, 1000, "SendSecureSMTP: Finished setting up the credentials necessary for the secure notification.."); string[] arrRecipients = ipNotification.get_Recipients(); for (int i = 0; i < arrRecipients.Length; ++i) { // Parse the recipient list to determine if they contain comma or semi-colon delimited // lists of individual recipients arrRecipients[i] = arrRecipients[i].Replace(',', ';'); string[] subRecipients = arrRecipients[i].Split(';'); foreach (string recipient in subRecipients) { MailMessage mailMessage; try { LogMessage(5, 1000, "SendSecureSMTP: Sending email from: " + ipNotification.SenderEmail + ", with subject: " + ipNotification.Subject + ", to: " + arrRecipients[i]); MailAddress From = new MailAddress(ipNotification.SenderEmail, ipNotification.SenderDisplayName); MailAddress To = new MailAddress(arrRecipients[i]); mailMessage = new MailMessage(From, To); mailMessage.Sender = new MailAddress(ipNotification.SenderEmail, ipNotification.SenderDisplayName); mailMessage.Subject = ipNotification.Subject; mailMessage.Body = ipNotification.MessageBody; mailMessage.IsBodyHtml = m_bHTMLSupport; } catch (Exception ex) { String strMessage = ex.Message; Exception innerEx = ex.InnerException; while (innerEx != null) { // Build the error message containing all the inner exceptions, as they are used by the mail client strMessage += " -> " + innerEx.Message; innerEx = innerEx.InnerException; } LogMessage(5, 1000, "SendSecureSMTP: Caught an exception: " + strMessage + ", continuing onto the next recipient.. "); continue; } mailClient.EnableSsl = true; mailClient.Send(mailMessage); LogMessage(5, 1000, "SendSecureSMTP: Finished sending email from: " + ipNotification.SenderEmail + ", with subject: " + ipNotification.Subject + ", to: " + arrRecipients[i]); } } } catch (Exception ex) { String strMessage = ex.Message; Exception innerEx = ex.InnerException; while (innerEx != null) { // Build the error message containing all the inner exceptions, as they are used by the mail client strMessage += " -> " + innerEx.Message; innerEx = innerEx.InnerException; } LogMessage(5, 1000, "SendSecureSMTP: Caught an exception: " + strMessage); } }