public static IEnumerable <string> attachmentList(string olFolderName, string containedSubject) { MailItem findedItem; bool hasMailFounded = OutlookSimpleApi.hasMailReceived(olFolderName, containedSubject, out findedItem); if (hasMailFounded) { for (int i = 0; i < findedItem.Attachments.Count; i++) { yield return(findedItem.Attachments[i].FileName); } } }
public static void saveAttachedFilesAtSpecificDate(DateTime date, string olFolderName, string saveDirectory) { if (olFolderName == null) { throw new ArgumentNullException(paramName: nameof(olFolderName)); } MAPIFolder olFolder = OutlookSimpleApi.getMailFolder(olFolderName); List <MailItem> mailsAtDate = (from m in olFolder.Items.OfType <MailItem>() where m.ReceivedTime.Date == date.Date select m).ToList(); mailsAtDate.ForEach(m => { var attachment = m.Attachments.OfType <Attachment>(); attachment.ToList().ForEach(a => { saveAttachedFiles(saveDirectory, a); }); }); }