none
Search Email Body Content RRS feed

  • Question

  • Hi,

        I want to search for Email Body content. I am using urn:schemas:httpmail:textdescription. But it searches the text in attachments too. How to search only email only email body text?

    Thanks

    Thursday, July 26, 2018 8:28 AM

All replies

  • Hello,

    It is not clear what code is used for searching Outlook items.

    However, you are on the right avenue. The How to: Search for a Phrase in the Body of Items in a Folder  article provides the following sample code for getting that done:

    private void DemoSearchBody()
    {
        string filter;
        if (Application.Session.DefaultStore.IsInstantSearchEnabled)
        {
            filter = "@SQL=" + "\""
                + "urn:schemas:httpmail:textdescription" + "\""
                + " ci_phrasematch 'office'";
        }
        else
        {
            filter = "@SQL=" + "\""
                + "urn:schemas:httpmail:textdescription" + "\""
                + " like '%office%'";
        }
        Outlook.Table table = Application.Session.GetDefaultFolder(
            Outlook.OlDefaultFolders.olFolderInbox).GetTable(
            filter, Outlook.OlTableContents.olUserItems);
        while (!table.EndOfTable)
        {
            Outlook.Row row = table.GetNextRow();
            Debug.WriteLine(row["Subject"]);
        }
    }

    Does it work for you correctly?


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Thursday, July 26, 2018 5:11 PM