private EmailMessage[] GetMessageInfos(bool pushNotification, string contentListPath) { var contentList = Node.LoadNode(contentListPath); var mailboxEmail = contentList["ListEmail"] as string; if (!pushNotification) { var service = ExchangeHelper.CreateConnection(mailboxEmail); if (service == null) { return(new EmailMessage[0]); } var items = ExchangeHelper.GetItems(service, mailboxEmail); var infos = items.Select(item => EmailMessage.Bind(service, item.Id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Body, ItemSchema.Attachments, ItemSchema.MimeContent))); return(infos.ToArray()); } else { var incomingEmails = SenseNet.Search.ContentQuery.Query(ContentRepository.SafeQueries.InFolder, new Search.QuerySettings { EnableAutofilters = FilterStatus.Disabled }, RepositoryPath.Combine(contentListPath, ExchangeHelper.PUSHNOTIFICATIONMAILCONTAINER)); if (incomingEmails.Count == 0) { return(new EmailMessage[0]); } var service = ExchangeHelper.CreateConnection(mailboxEmail); if (service == null) { return(new EmailMessage[0]); } var msgs = new List <EmailMessage>(); foreach (var emailnode in incomingEmails.Nodes) { var ids = emailnode["Description"] as string; if (string.IsNullOrEmpty(ids)) { continue; } var idList = ids.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var id in idList) { var msg = EmailMessage.Bind(service, id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Body, ItemSchema.Attachments, ItemSchema.MimeContent)); msgs.Add(msg); } // delete email node emailnode.ForceDelete(); } return(msgs.ToArray()); } }
private EmailMessage GetMessageInfo(string itemId, string email) { var service = ExchangeHelper.CreateConnection(email); if (service == null) { return(null); } var item = ExchangeHelper.GetItem(service, itemId); var message = EmailMessage.Bind(service, item.Id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Body, ItemSchema.Attachments, ItemSchema.MimeContent)); return(message); }