private void ThisAddIn_Startup(object sender, EventArgs e) { // get the explorers. _explorers = Application.Explorers; // get all the folders. _folders = Application.Session.DefaultStore.GetRootFolder().Folders; // create all the required values. Create(); // new email arrives. Application.NewMailEx += Application_NewMailEx; // start all the values Start(); // do we want to check unprocessed emails? if (TheEngine.Options.CheckUnProcessedEmailsOnStartUp) { TasksController.Add(ParseUnprocessedEmailsAsync()); } // log the version LogStartupInformation(); }
public void Monitor(Outlook._Folders folders) { // remove whatever we might be monitoring UnRegisterAllFolders(); // then start monitoring RegisterAllFolders(folders); }
/// <summary> /// Process all the un-processed emails in the given folder. /// </summary> /// <param name="folders"></param> /// <param name="limit"></param> /// <param name="includeSubfolders"></param> /// <param name="token"></param> public async Task ProcessAsync(Outlook._Folders folders, int limit, bool includeSubfolders, CancellationToken token) { // get the last time we processed an email and create a filter for it. var lastProccessed = _mailprocessor.LastProcessed; var filter = $"[ReceivedTime]>'{lastProccessed:g}'"; // log the filter. _logger.LogVerbose($"Looking for messages received after : '{lastProccessed:g}'"); // then parse all the folders. var ids = GetUnprocessedEmailsInFolders(folders, limit, includeSubfolders, filter, token); // we are done with the progress bar CloseProgressBar(); // we can then add the ids we have to be processed. await _mailprocessor.AddAsync(ids).ConfigureAwait(false); }
private Outlook.MAPIFolder GetCalendarFolderByName(Outlook._Folders folder, string name) { foreach (Outlook.MAPIFolder Folder in folder) { if (Folder.Name == name) { return(Folder); } else { Outlook.MAPIFolder rtrnFolder = GetCalendarFolderByName(Folder.Folders, name); if (rtrnFolder != null) { return(rtrnFolder); } } } return(null); }