Tuesday, October 18, 2011

Use Instant Search to Search All Folders and All Stores for a Phrase in the Subject

//namespace Add(Microsoft.Office.Interop.Outlook.dll)

using Outlook = Microsoft.Office.Interop.Outlook;
//code
private void SearchInOutlook()
{
    if (Application.Session.DefaultStore.IsInstantSearchEnabled)
    {
        Outlook.Explorer explorer = Application.Explorers.Add(
            Application.Session.GetDefaultFolder(
            Outlook.OlDefaultFolders.olFolderInbox)
            as Outlook.Folder,
            Outlook.OlFolderDisplayMode.olFolderDisplayNormal);
//this will search for subject.        
string filter = "subject:" +
            "\"" + "Office 2007" + "\"" +
            " received:(last month)";
        explorer.Search(filter,
            Outlook.OlSearchScope.olSearchScopeAllFolders);
        explorer.Display();
    }
}

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs) directly on your computer.

    LM Studio Overview LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs...