Foggy Bottoms has asked for the wisdom of the Perl Monks concerning the following question:

     I need to write a method that returns an email object, as specified in the Outlook object library, and I thought I'd do it based on its entry ID.
     If you have a look at OLE properties in Outlook, you'll notice there's an object called mailitem and that this item has a property called EntryID which I'd like to use to find a specific mail : I want to use the items->Find() method which uses a filter but somehow I can't get it to work. I read somewhere on a VB forum that the filter was a string looking very much like "EntryID=".$EntryID
     Does anyone know how to use this filter ? I've tried to look but unfortunately I didn't find anything interesting...

     I'd appreciate if anyone could help me, thanks...

Replies are listed 'Best First'.
Re: Outlook Ole Find method
by BrowserUk (Patriarch) on Aug 04, 2003 at 12:05 UTC

    I haven't had to Outlook for a few years now, so I'm running from memory here, but try

    ... $items->Find( "[EntryID] = \"$entryID\"" );

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

      It seems nice to activate in my code, Unfortunately doesn't work properly. It seems a problem in filter string

      "[EntryID] = \"$entryID\"".

      I want to do it with multiple properties such as Subject, SenderName, etc.
      If you have further clarification or anyone else...?

        If I recall, the basic syntax is

        ... $items->Find( '[Subject] = ' . $subject1 . ' or [Subject] = ' . $subject2 . ' and [SenderName] = ' . $sender );

        You'll need to look up the MS docs for the list of available categories and the full syntax. My memory isn't what it once was:)


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
        If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: Outlook Ole Find method
by jdporter (Paladin) on Aug 04, 2003 at 18:04 UTC
    Not sure why you want to use Find. If you have the EntryID, no other criteria are necessary (or, indeed, usable). You can get the item directly from the Namespace (i.e. Session) object:
    $item = $outlook->GetNamespace('MAPI')->GetItemFromID( $entry_id );

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.

      You're quite right, I hadn't seen that option. Thanks so much for the tip, it works beautifully now.

      Heureux qui, comme Ulysse, a fait un beau voyage
      Ou comme celui-là qui conquit la Toison,
      Et puis est retourné plein d'usage et raison,
      Vivre entre ses parents le reste de son âge!

      J. du Bellay, poète angevin