Esempio n. 1
0
        /// <summary>
        /// Copies the email entity to mail message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        private MailMessage CopyEmailEntityToMailMessage(EmailEntity message)
        {
            MailMessage outputMessage = new MailMessage();

            outputMessage.Subject = message.Subject;
            outputMessage.From    = EmailUtil.CreateMailAddress(message.From);
            outputMessage.To.Add(EmailUtil.CreateMailAddress(message.To));

            if (!string.IsNullOrEmpty(message.MessageContext))
            {
                outputMessage.MessageContent = message.MessageContext;
            }
            else
            {
                outputMessage.IsBodyHtml = true;
                outputMessage.Body       = message.HtmlBody;
            }
            return(outputMessage);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates the mail address.
 /// </summary>
 /// <param name="email">The email.</param>
 /// <returns></returns>
 public static MailAddress CreateMailAddress(string email)
 {
     return(new MailAddress(EmailUtil.ExtractFirstEmail(email), EmailUtil.ExtractFirstShowName(email)));
 }