示例#1
0
 public static MailAddress ConvertToMailAddress(MailerRecipient recipient)
 {
     MailAddress mailAddress;
     if (!string.IsNullOrEmpty(recipient.EmailAddress) && !string.IsNullOrEmpty(recipient.RecipientName))
     {
         mailAddress = new MailAddress(recipient.EmailAddress, recipient.RecipientName);
     }
     else if (!string.IsNullOrEmpty(recipient.EmailAddress))
     {
         mailAddress = new MailAddress(recipient.EmailAddress);
     }
     else
     {
         mailAddress = null;
     }
     return mailAddress;
 }
示例#2
0
 /// <summary>
 /// Creates a mailer object from template.  Quick compose to send to one recipient only. 
 /// </summary>
 /// <param name="orgUnitID"></param>
 /// <param name="mailTemplateCode"></param>
 /// <param name="messageTokenValues"></param>
 /// <param name="emailTo"></param>
 /// <param name="subjectTokenValues"></param>
 /// <param name="emailCC"></param>
 /// <param name="emailBcc"></param>
 public void Compose( string mailTemplateCode, Hashtable messageTokenValues, string emailTo, string emailCC = null, string emailBcc = null, List<MailerAttachment> attachments = null)
 {
     MailerRecipient to = new MailerRecipient(emailTo);
     List<MailerRecipient> toList = new List<MailerRecipient>();
     toList.Add(to);
     List<MailerRecipient> ccList = null;
     if (!string.IsNullOrEmpty(emailCC))
     {
         MailerRecipient cc = new MailerRecipient(emailCC);
         if (ccList == null) ccList = new List<MailerRecipient>();
         ccList.Add(cc);
     }
     List<MailerRecipient> bccList = null;
     if (!string.IsNullOrEmpty(emailBcc))
     {
         MailerRecipient bcc = new MailerRecipient(emailBcc);
         if (bccList == null) bccList = new List<MailerRecipient>();
         bccList.Add(bcc);
     }
     Compose(mailTemplateCode, messageTokenValues, toList, ccList, bccList, attachments);
 }