/// <summary> /// Sends an E-mail with the EMailClass Object Information /// </summary> /// <param name="oEMailClass">Mail's Propierties Class</param> public void EnviarEMailClass(EMailClass oEMailClass) { try { MailMessage oMailMessage = new MailMessage(); oMailMessage.To.Add(oEMailClass.To); if (!string.IsNullOrEmpty(oEMailClass.CC)) oMailMessage.CC.Add(oEMailClass.CC); oMailMessage.Subject = oEMailClass.Subject; oMailMessage.From = new MailAddress(ConfigurationManager.AppSettings["MailUser"].ToString()); oMailMessage.IsBodyHtml = true; if (!string.IsNullOrEmpty(oEMailClass.Attachment)) oMailMessage.Attachments.Add(new Attachment(oEMailClass.Attachment)); oMailMessage.Body = oEMailClass.Message; oMailMessage.Priority = MailPriority.Normal; SmtpClient oSmtpClient = new SmtpClient(ConfigurationManager.AppSettings["MailSmtp"].ToString()); oSmtpClient.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["MailUser"].ToString(), ConfigurationManager.AppSettings["MailPass"].ToString()); oSmtpClient.Send(oMailMessage); oMailMessage.Dispose(); } catch (SmtpException ex) { throw new SmtpException("Houve um problema no envio de e-mail \n" + ex.ToString()); } }
/// <summary> /// Sends an E-mail with the EMailClass Object Information /// </summary> /// <param name="oEMailClass">Mail's Propierties Class</param> public void EnviarEMailClass(EMailClass oEMailClass) { try { MailMessage oMailMessage = new MailMessage(); oMailMessage.To.Add(oEMailClass.To); if (!string.IsNullOrEmpty(oEMailClass.CC)) { oMailMessage.CC.Add(oEMailClass.CC); } oMailMessage.Subject = oEMailClass.Subject; oMailMessage.From = new MailAddress(ConfigurationManager.AppSettings["MailUser"].ToString()); oMailMessage.IsBodyHtml = true; if (!string.IsNullOrEmpty(oEMailClass.Attachment)) { oMailMessage.Attachments.Add(new Attachment(oEMailClass.Attachment)); } oMailMessage.Body = oEMailClass.Message; oMailMessage.Priority = MailPriority.Normal; SmtpClient oSmtpClient = new SmtpClient(ConfigurationManager.AppSettings["MailSmtp"].ToString()); oSmtpClient.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["MailUser"].ToString(), ConfigurationManager.AppSettings["MailPass"].ToString()); oSmtpClient.Send(oMailMessage); oMailMessage.Dispose(); } catch (SmtpException ex) { throw new SmtpException("Houve um problema no envio de e-mail \n" + ex.ToString()); } }