Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How do I search for Subject Title in Outlook?

by Kanji (Parson)
on Oct 31, 2005 at 15:00 UTC ( #504281=note: print w/ replies, xml ) Need Help??


in reply to How do I search for Subject Title in Outlook?

Win32::OLE works great for accessing Outlook from Perl, with the below iterating over all the messages in your Inbox (but possibly not sub-folders).

#!perl use strict; use warnings; use Win32::OLE 'in'; use Win32::OLE::Const 'Microsoft Outlook'; # olFolderInbox my $outlook = Win32::OLE->GetActiveObject('Outlook.Application') or do { my $reason = Win32::FormatMessage(Win32::GetLastError()); die "Cannot get active Outlook object: $reason"; }; my $namespace = $outlook->GetNamespace('MAPI'); if (my $folder = $namespace->GetDefaultFolder(olFolderInbox)) { print $folder->Name, "\n"; foreach my $email (in $folder->Items) { print " ", $email->Subject, "\n" if $email->Subject eq 'Build 50.2'; # Do something with $email. } }

However, if you do plan on doing something further with $email once you've found the right message, it is essential that you use ActivePerl's OLE browser, thumb through the MSDN Library and/or Google liberally for example usage as knowing what to access or look for in the OLE objects is 99% of the battle!

    --k.


Update: s/ eq /\n if $email->Subject eq /; # oops


Comment on Re: How do I search for Subject Title in Outlook?
Download Code
Re2: How do I search for Subject Title in Outlook?
by gasho (Beadle) on Oct 31, 2005 at 15:44 UTC
    Thanks A Lot. You saved my day :) Gasho

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://504281]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-12-28 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls