Exemple #1
0
 public void AddBCCRecipient(string address, string display, EnumCharEncode displayEncoding)
 {
     foreach (MailAddress a in _message.Bcc)
     {
         if (string.Compare(a.Address, address, StringComparison.OrdinalIgnoreCase) == 0)
         {
             return;
         }
     }
     _message.Bcc.Add(new MailAddress(address, display, EncodeUtility.GetEncoding(displayEncoding)));
 }
Exemple #2
0
 private void prepareMessage()
 {
     if (!string.IsNullOrEmpty(_senderAddress))
     {
         _message.Sender = new MailAddress(_senderAddress, _senderDisplay, EncodeUtility.GetEncoding(_senderDisplayEncode));
     }
     if (!string.IsNullOrEmpty(_fromAddress))
     {
         _message.From = new MailAddress(_fromAddress, _fromDisplay, EncodeUtility.GetEncoding(_fromDisplayEncode));
     }
     if (!string.IsNullOrEmpty(_replyToAddress))
     {
         _message.ReplyTo = new MailAddress(_replyToAddress, _replyToDisplay, EncodeUtility.GetEncoding(_replyToDisplayEncode));
     }
     if (IsBodyHtml || (_embededImages != null && _embededImages.Count > 0))
     {
         AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, EncodeUtility.GetEncoding(_bodyEncoding), "text/html");
         _message.AlternateViews.Add(htmlView);
         if (_embededImages != null && _embededImages.Count > 0)
         {
             foreach (KeyValuePair <string, string> kv in _embededImages)
             {
                 LinkedResource lr = new LinkedResource(kv.Value);
                 lr.ContentId = kv.Key;
                 htmlView.LinkedResources.Add(lr);
             }
         }
     }
     _message.Attachments.Clear();
     if (_attachments != null && _attachments.Length > 0)
     {
         for (int i = 0; i < _attachments.Length; i++)
         {
             _message.Attachments.Add(new Attachment(_attachments[i]));
         }
     }
     if (!UseDefaultCredentials)
     {
         NetworkCredential c = new NetworkCredential(UserAccount, UserPassword, UserDomain);
         _smtp.Credentials = c;
     }
 }