public void AddToRecipients(IEnumerable <SourceAddress> recipients)
 {
     foreach (var recipient in recipients)
     {
         ToRecipients.AddRecipient(mailbox.Find(recipient));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Method Name     : AddRecipients
        /// Author          : Jitendra Garg
        /// Creation Date   : 15 Jan 2018
        /// Purpose         : Adds recipients to the mail object (Reduces cognitive complexity of AddMessage function
        /// Revision        :
        /// </summary>
        private void AddRecipients()
        {
            string[] mailAddress = null;

            if (!string.IsNullOrEmpty(ToRecipients))
            {
                mailAddress = ToRecipients.Split(',');
                foreach (string strRecp in mailAddress)
                {
                    emailMessage.To.Add(new MailAddress(strRecp));
                }
            }
            if (!string.IsNullOrEmpty(BccRecipients))
            {
                mailAddress = BccRecipients.Split(',');
                foreach (string strRecp in mailAddress)
                {
                    emailMessage.Bcc.Add(new MailAddress(strRecp));
                }
            }

            if (!string.IsNullOrEmpty(CcRecipients))
            {
                mailAddress = CcRecipients.Split(',');
                foreach (string strRecp in mailAddress)
                {
                    emailMessage.CC.Add(new MailAddress(strRecp));
                }
            }
        }
 public void AddToRecipients(IEnumerable <Profile> recipients)
 {
     foreach (var recipient in recipients)
     {
         ToRecipients.AddRecipient(recipient);
     }
 }
        /// <summary>
        /// TODO - Flatten body (use my SQL Flattern pattern)
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var toItems = string.Join(";", ToRecipients.ToArray());
            var ccItems = string.Join(";", CCRecipients.ToArray());

            return($"'{Sender}','{Subject}', '{toItems}', '{ccItems}', {AttachmentCount}");
        }
Beispiel #5
0
        /// <summary>
        ///     Creates a <c>BulkDeleteRequest</c>.
        /// </summary>
        /// <param name="queries">The queries which returns the records to delete.</param>
        /// <returns>A <c>BulkDeleteRequest</c> object.</returns>
        private BulkDeleteRequest CreateBulkDeleteRequest(IEnumerable <QueryExpression> queries)
        {
            var bulkDeleteRequest = new BulkDeleteRequest
            {
                JobName               = String.IsNullOrEmpty(BulkDeleteOperationName) ? "Bulk Delete - " + DateTime.Now.ToString("g") : BulkDeleteOperationName,
                QuerySet              = queries.ToArray(),
                StartDateTime         = StartTime == DateTime.MinValue ? DateTime.Now : StartTime,                      // Default is start immediately
                RecurrencePattern     = RecurrencePattern ?? String.Empty,                                              // Default is none (empty)
                SendEmailNotification = SendEmailNotification,                                                          // Default is false
                ToRecipients          = ToRecipients == null ? new Guid[0] : ToRecipients.Select(Guid.Parse).ToArray(), // Default is none (empty)
                CCRecipients          = CcRecipients == null ? new Guid[0] : CcRecipients.Select(Guid.Parse).ToArray(), // Default is none (empty)
            };

            return(bulkDeleteRequest);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ExchangeEmailMessage" /> class.
        /// </summary>
        /// <param name="email">The <see cref="ExchangeMessage" /> retrieved from the Exchange server.</param>
        /// <exception cref="ArgumentNullException"><paramref name="email" /> is null.</exception>
        internal ExchangeEmailMessage(ExchangeMessage email)
        {
            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }

            ExchangeId       = email.Id;
            DateTimeSent     = email.DateTimeSent;
            DateTimeReceived = email.DateTimeReceived;
            Subject          = email.Subject;
            Body             = email.Body;

            if (!string.IsNullOrEmpty(email.From?.Address))
            {
                try
                {
                    FromAddress = new MailAddress(email.From?.Address, email.From?.Name);
                }
                catch (FormatException)
                {
                    // Invalid From address.
                }
            }

            foreach (EmailAddress toRecipient in email.ToRecipients)
            {
                ToRecipients.Add(new MailAddress(toRecipient.Address, toRecipient.Name));
            }

            foreach (EmailAddress ccRecipient in email.CcRecipients)
            {
                CcRecipients.Add(new MailAddress(ccRecipient.Address, ccRecipient.Name));
            }

            if (email.HasAttachments)
            {
                foreach (FileAttachment file in email.Attachments)
                {
                    Attachments.Add(new ExchangeEmailAttachment(file));
                }
            }

            foreach (var header in email.InternetMessageHeaders)
            {
                Headers[header.Name] = header.Value;
            }
        }
 public void ClearRecipients()
 {
     ToRecipients.ClearRecipients();
     CcRecipients.ClearRecipients();
     BccRecipients.ClearRecipients();
 }
 public void AddToRecipient(Profile profile)
 {
     ToRecipients.AddRecipient(profile);
 }
 public void AddToRecipient(SourceAddress recipient)
 {
     ToRecipients.AddRecipient(mailbox.Find(recipient));
 }