public SmtpClient CreateSmtpClient(IMsgContext msgContext) { var smtpClient = new SmtpClient(); smtpClient.Host = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_HOST); smtpClient.Port = Convert.ToInt32(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_PORT)); smtpClient.EnableSsl = msgContext.GetConfigValue(IFConfigPropertyNames.SMTP_ENABLESSL, false); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_FROM), msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_PASSWORD)); return(smtpClient); }
public MailMessage GenerateMailMessage(IMsgContext msgContext) { var messageFromAddress = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_FROM); var messageToAddresses = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_TO); var messageFrom = new MailAddress(messageFromAddress); var messageTo = new MailAddress(messageToAddresses); var message = new MailMessage(messageFrom, messageTo); message.CC.Add(messageFrom); message.Subject = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_SUBJECT); message.Body = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_BODY); message.Attachments.Add(AddAttachment(msgContext)); return(message); }
public Attachment AddAttachment(IMsgContext msgContext) { return(new Attachment(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.FILE_PATH), MediaTypeNames.Application.Octet)); }