none
How to find match in Calendar item subject with case sensitive and partial match RRS feed

  • Question

  • Hi,

    I try to find match in Calendar item subject by following code,

                    // Get Calendar folder
                    Outlook.MAPIFolder myCalendar = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
    
                    // Get the Items collection from the Calendar folder.
                    Outlook.Items items = myCalendar.Items;
    
                    string filter = "[Subject] = '"
                       + searchString + "'";
    
                    items = items.Restrict(filter);
     

    It works only for case insensitive and whole word match of "searchString". How to find partial match of "searchString" and case sensitive? Thanks.

    York



    York

    Tuesday, September 24, 2013 7:32 AM

Answers

All replies

  • You can use ci_startwith in your query (http://msdn.microsoft.com/en-us/library/office/ff869374.aspx ), but I don't think Outlook Object Model will let you use case-sensitive comparison. You can drop down to the Extended MAPI level (C++ or Delphi) or Redemption and create a RES_CONTENT/FL_SUBSTRING restriction without the FL_IGNORECASE flag (see http://www.dimastr.com/redemption/mapitable.htm#rescontent for a Redemption example)


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

    Tuesday, September 24, 2013 5:26 PM
  • Thanks Dmitry. The problem is that how to specify [Subject] (property name to be searched)  in the query,

    criteria = "@SQL=" & Chr(34) _ & "urn:schemas:contacts:sn" & Chr(34) _ & " ci_phrasematch 'Smith'"

    Another thing is that can "@SQL" ... be combined with date range query like,

    "[Start] >= '"
    + dateTimePicker_FromDate.Value.ToString("g")
    + "' AND [Start] <= '"
    + dateTimePicker_ToDate.Value.ToString("g")
    + "' AND @SQL= ...'"


    York


    • Edited by york Z Wednesday, September 25, 2013 5:41 AM
    Wednesday, September 25, 2013 5:28 AM
  • One more question, I want to do query on outlook calendar items like,

    Outlook.MAPIFolder myCalendar = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
                  
    Outlook.Items items = myCalendar.Items;
    
    var restrictItems = (from item in items
                        where item.Start >= dateTimePicker_FromDate.Value && item.Start <= dateTimePicker_ToDate.Value
                        select item).ToList();
    

    However, it gives error that

    Error    1    Could not find an implementation of the query pattern for source type 'Microsoft.Office.Interop.Outlook.Items'.  'Where' not found.  Consider explicitly specifying the type of the range variable 'item'.

    What is the problem?

    Thanks,


    York

    Wednesday, September 25, 2013 5:40 AM
  • Do not use LING with Outlook collections (even if you could) - the search will be performed on the client side. Do use Items.Find/Restrict.

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

    Thursday, October 3, 2013 5:22 AM