コード例 #1
0
        public IEnumerable <IIncomingEmailMessage> GetMessages()
        {
            Logger.InfoFormat("Getting email messages...");
            var itemCount = _folder.TotalCount;

            if (itemCount <= 0)
            {
                return(new List <IIncomingEmailMessage>());
            }

            List <Item> items = new List <Item>();

            // Gets new email messages that were recieved after the initial startup.
            GetEventsResults eventResults = subscription.GetEvents();

            foreach (ItemEvent itemEvent in eventResults.ItemEvents)
            {
                Item item = Item.Bind(_folder.Service, itemEvent.ItemId);
                items.Add(item);
            }

            // Gets new email messages on the initial startup.
            var         view       = new ItemView(itemCount);
            List <Item> itemsToAdd = _folder.FindItems(view).ToList();

            items.AddRange(itemsToAdd);

            Logger.InfoFormat("Items found: {0}", items.Count());

            var messages  = new List <IIncomingEmailMessage>();
            int junkCount = 0;

            foreach (var item in items)
            {
                if (item is EmailMessage)
                {
                    EWSIncomingMessage message = new EWSIncomingMessage((EmailMessage)item);
                    messages.Add(message);
                }
                else
                {
                    junkCount++;
                    item.Move(WellKnownFolderName.DeletedItems);
                }
            }

            Logger.InfoFormat("Message count: {0}, Junk count: {1}", messages.Count, junkCount);
            Logger.InfoFormat("Completed getting messages.");
            return(messages);
        }
コード例 #2
0
 private static void MoveMessageToFolder(EWSIncomingMessage ewsMessage, Folder rogueMessageFolder)
 {
     try
     {
         Logger.InfoFormat("Moving mail item to '{0}' folder.", rogueMessageFolder.DisplayName);
         ewsMessage.MoveMessage(rogueMessageFolder.Id);
     }
     catch (Exception)
     {
         Logger.ErrorFormat(
             "Failed to move message to '{0}' folder. Possible cause: original mail item moved by the Exchange Server rules.",
             rogueMessageFolder.DisplayName);
     }
 }
コード例 #3
0
        public IEnumerable <IIncomingEmailMessage> GetMessages()
        {
            Logger.InfoFormat("Getting email messages...");
            var itemCount = _folder.TotalCount;

            if (itemCount <= 0)
            {
                return(new List <IIncomingEmailMessage>());
            }

            var view  = new ItemView(itemCount);
            var items = _folder.FindItems(view);

            Logger.InfoFormat("Items found: {0}", items.Count());

            var messages  = new List <IIncomingEmailMessage>();
            int junkCount = 0;

            foreach (var item in items)
            {
                if (item is EmailMessage)
                {
                    EWSIncomingMessage message = new EWSIncomingMessage((EmailMessage)item);
                    messages.Add(message);
                }
                else
                {
                    junkCount++;
                    item.Move(WellKnownFolderName.DeletedItems);
                }
            }

            Logger.InfoFormat("Message count: {0}, Junk count: {1}", messages.Count, junkCount);
            Logger.InfoFormat("Completed getting messages.");
            return(messages);
        }
コード例 #4
0
 /// <summary>
 /// Process a single message based on whether it was processed successfully or not
 /// </summary>
 public void Process(EWSIncomingMessage message, bool successful)
 {
     var destination = successful ? _successFolderId : _failureFolderId;
     message.MoveMessage(destination);
 }
コード例 #5
0
 private static void MoveMessageToFolder(EWSIncomingMessage ewsMessage, Folder rogueMessageFolder)
 {
     try
     {
         Logger.InfoFormat("Moving mail item to '{0}' folder.", rogueMessageFolder.DisplayName);
         ewsMessage.MoveMessage(rogueMessageFolder.Id);
     }
     catch (Exception)
     {
         Logger.ErrorFormat(
             "Failed to move message to '{0}' folder. Possible cause: original mail item moved by the Exchange Server rules.",
             rogueMessageFolder.DisplayName);
     }
 }
コード例 #6
0
 private void HandleEWSMessage(EWSIncomingMessage originalMessage, string workItemId)
 {
     originalMessage.Reply(GetReplyContents(workItemId), _config.EmailSettings.AckEmailsRecipientsAll);
 }
コード例 #7
0
        /// <summary>
        /// Process a single message based on whether it was processed successfully or not
        /// </summary>
        public void Process(EWSIncomingMessage message, bool successful)
        {
            var destination = successful ? _successFolderId : _failureFolderId;

            message.MoveMessage(destination);
        }