private static async Task <List <EmailFileAttachment> > ConvertAttachmentCollection(AttachmentCollection attachmenCollection) { var emailFileAttachments = new EditableList <EmailFileAttachment>(); var fileAttachments = attachmenCollection.Where(attachment => attachment is FileAttachment); foreach (var fileAttachment in fileAttachments) { var emailFileAttachment = await ExchangeHandler.ConvertFileAttachment(fileAttachment as FileAttachment); emailFileAttachments.Add(emailFileAttachment); } return(emailFileAttachments); // return attachmenCollection.Where(attachment => attachment is FileAttachment).Select(async attachment => await ExchangeHandler.ConvertFileAttachment(attachment as FileAttachment)).ToList(); }
private async Task <Email> ConvertEmailMessage(EmailMessage emailMessage) { this.logger.DebugFormat("Converting email message [{0}] to email...", emailMessage.Subject); var email = new Email { FromAddress = emailMessage.From.ToString(), ToAddresses = ExchangeHandler.ConvertEmailAddressCollection(emailMessage.ToRecipients), CCAddresses = ExchangeHandler.ConvertEmailAddressCollection(emailMessage.CcRecipients), BCCAddresses = ExchangeHandler.ConvertEmailAddressCollection(emailMessage.BccRecipients), Subject = emailMessage.Subject, Body = emailMessage.Body, DateReceived = DateTime.Now, FileAttachments = await ExchangeHandler.ConvertAttachmentCollection(emailMessage.Attachments), MimeBytes = emailMessage.MimeContent.Content }; this.logger.DebugFormat("Email message [{0}] converted to email.", emailMessage.Subject); return(email); }