none
VSTO Office 2010 items.Restrict does not filter items RRS feed

  • Question

  • Thank you for reading the post.

    Please find below the extract of the code below which works for the outlook 2007 to restrict items in the collection of mail items but the same does not work for the outlook.

     MAPIFolder currentFolder = appObject.Session.GetFolderFromID(ID, Type.Missing);
    string sFilter = string.Empty;
    Microsoft.Office.Interop.Outlook.Items items = null;
    Microsoft.Office.Interop.Outlook.Items itemsOg = currentFolder.Items; 

    sFilter = "[Created] >= '" + dtStart.Value.Date.ToString("g") + "'" + " And " + "[Created] < '" + dtEnd.Value.Date.AddDays(1).ToString("g") + "'"; 
    items = itemsOg.Restrict(sFilter);

     foreach (Object item in items)
                {

    }

    FYI.. I have also tried the LastModifiedTime instead of the Created field. 

    Cheers,

    :)

    Monday, February 27, 2012 4:15 AM

Answers

  • The property names are CreationTime and LastModificationTime.

    Are you sure the items that are supposed to match have the expected values of the properties? Do you see the right values in oUtlookSpy if you click the Item button and look at these properties?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    • Marked as answer by Veenit M Thursday, March 1, 2012 5:07 AM
    Monday, February 27, 2012 6:35 AM