Exemple #1
0
        public Outlook.Search RunAdvancedSearch(string wordInSubject)
        {
            string scope  = "Inbox";
            string filter = String.Format(
                "@SQL=(\"urn:schemas:calendar:datereceived\" >= '{0:g}' " +
                "AND \"urn:schemas:mailheader:subject\" LIKE '%{1}%')", DateTime.Today.ToString("g"), wordInSubject);

            string ff1 = "urn:schemas:httpmail:datereceived >= '" + DateTime.Today.ToString("g") + "' AND " +
                         "urn:schemas:mailheader:subject LIKE '%" + wordInSubject + "%' AND " +
                         "urn:schemas:mailheader:sender LIKE '%" + "*****@*****.**" + "%'";

            advancedSearch = null;
            Outlook.MAPIFolder folderInbox    = null;
            Outlook.MAPIFolder folderSentMail = null;
            Outlook.NameSpace  ns             = null;
            try {
                ns             = OApp.GetNamespace("MAPI");
                folderInbox    = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                folderSentMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
                scope          = "\'" + folderInbox.FolderPath + "\',\'" + folderSentMail.FolderPath + "\'";
                advancedSearch = OApp.AdvancedSearch(scope, ff1, true, advancedSearchTag);
                OApp.AdvancedSearchComplete += Application_AdvancedSearchComplete;
                return(advancedSearch);
            }
            catch (Exception ex) {
                Console.WriteLine("\n\tException: " + ex.Message);
                return(advancedSearch);
            }
        }
Exemple #2
0
 private void Application_AdvancedSearchComplete(Outlook.Search SearchObject)
 {
     try
     {
         object searchFolder = SearchObject.Save(SearchObject.Tag);
         if (CurrentSettings.IncomingSecondAction == IncomingSecondAction.CreateSearchFolderFavorite)
         {
             AddFolderToFavorites(searchFolder as Outlook.MAPIFolder);
         }
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry(EventLogSource, ex.Message, EventLogEntryType.Error, 3);
     }
 }
Exemple #3
0
        // Méthode permettant de catcher la fin de la recherche
        private void outlook_AdvancedSearchComplete(Outlook.Search searchObject)
        {
            // Vérification du nom de la recherche
            if (searchObject.Tag == "SearchMail" && searchObject.Results.Count > 0)
            {
                Outlook.MailItem mail = (Outlook.MailItem)searchObject.Results.GetFirst();
                mail.Display();//Affichage du mail
                //TODO: If found, update the EntryId of the record in the database so that future searches are fast.
            }
            else
            {
                TrayIcon.afficheMessage("Recherche Outlook", "pas de résultats");
            }

            // On sé désabonne de toutes les recherches avancées qui pourront être effectuées
            outlook.AdvancedSearchComplete -= outlook_AdvancedSearchComplete;
        }
 public void AdvancedSearchStopped(Outlook.Search SearchObject)
 {
     Utility.LogApplicationEvent(LogType.Event, (string.Format("{0}{1}", new StackTrace().GetFrame(0).GetMethod().Name, System.Environment.NewLine)));
 }
Exemple #5
0
 public void Application_AdvancedSearchComplete(Outlook.Search SearchObject)
 {
     isFinished = true;
 }