static IEnumerable<Microsoft.Exchange.WebServices.Data.Task> FindIncompleteTask(ExchangeService service)
        {
            // Specify the folder to search, and limit the properties returned in the result.
            TasksFolder tasksfolder = TasksFolder.Bind(service,
                                                       WellKnownFolderName.Tasks,
                                                       new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount));

            // Set the number of items to the smaller of the number of items in the Contacts folder or 1000.
            int numItems = tasksfolder.TotalCount < 1000 ? tasksfolder.TotalCount : 1000;

            // Instantiate the item view with the number of items to retrieve from the contacts folder.
            ItemView view = new ItemView(numItems);

            // To keep the request smaller, send only the display name.
            view.PropertySet = new PropertySet(BasePropertySet.IdOnly, TaskSchema.Subject, TaskSchema.Status, TaskSchema.StartDate);

            var filter = new SearchFilter.IsGreaterThan(TaskSchema.DateTimeCreated, DateTime.Now.AddYears(-10));

            // Retrieve the items in the Tasks folder with the properties you selected.
            FindItemsResults<Microsoft.Exchange.WebServices.Data.Item> taskItems = service.FindItems(WellKnownFolderName.Tasks, filter, view);

            // If the subject of the task matches only one item, return that task item.
            var results = new List<Microsoft.Exchange.WebServices.Data.Task>();
            foreach (var task in taskItems)
            {
                var result = new Microsoft.Exchange.WebServices.Data.Task(service);
                result = task as Microsoft.Exchange.WebServices.Data.Task;
                results.Add(result);
            }
            return results;
        }
Beispiel #2
0
        protected void CheckMailHandler(object o, EventArgs e)
        {
            _timer.Stop();

            FindItemsResults<Item> findResults;
            SearchFilter sf = new SearchFilter.IsGreaterThan(ItemSchema.DateTimeReceived, _latestMessageDate);

            //process the Inbox
            findResults = _exchangeService.FindItems(WellKnownFolderName.Inbox, sf, new ItemView(10));
            if (findResults.Items.Count > 0)
                ProcessResults(findResults);

            // and process all the other folders too
            foreach (Folder folder in _folders.Folders)
            {
                findResults = _exchangeService.FindItems(folder.Id, sf, new ItemView(10));
                if (findResults.Items.Count > 0)
                    ProcessResults(findResults);
            }
            _timer.Start();
        }
Beispiel #3
0
        /// <summary>
        /// Permet d'obtenir la liste des emails
        /// </summary>
        public override void GetListOfEmails()
        {
            #region Déclaration des variables

            ItemView view = new ItemView(int.MaxValue);
            SearchFilter searchFilter = new SearchFilter.IsGreaterThan(ItemSchema.DateTimeReceived, DateTime.Now);

            FindItemsResults<Item> findResults = SERVICE.FindItems(WellKnownFolderName.Inbox, searchFilter, view);

            #endregion

            foreach (EmailMessage item in findResults.Items)
            {
                Console.WriteLine("Date : " + item.DateTimeReceived);
                Console.WriteLine("From : " + item.Sender);
                Console.WriteLine("Sujet : " + item.Subject + "\n");
            }
        }