示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 public Attachment AddAttachment(IMsgContext msgContext)
 {
     return(new Attachment(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.FILE_PATH), MediaTypeNames.Application.Octet));
 }