Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Outlook & Win32::OLE

by Anonymous Monk
on Aug 17, 2004 at 10:04 UTC ( #383597=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks

I am looking at a script that uses Win32::OLE to read 'unread mails' from MS Outlook. Can anybody give me a sample script?

Thanks in advance

Comment on Outlook & Win32::OLE
Re: Outlook & Win32::OLE
by tachyon (Chancellor) on Aug 17, 2004 at 11:00 UTC

    Microsoft destroyed virtually all automation of Outlook about 4 years ago to stop worms, etc. Blunt shotgun approach. There are all sorts of work arounds. Try SuperSearch for some of the info. It is typically ugly. Don't go there if you don't have to.

    Reading is a lot easier than *writing* ie using MAPI to send mail.

    cheers

    tachyon

Re: Outlook & Win32::OLE
by maa (Pilgrim) on Aug 17, 2004 at 11:53 UTC

    Example code for accessing a "shared mailbox subfolder"...

    use strict; use warnings; use Win32::OLE::Const 'Microsoft Outlook'; use Win32::OLE 'in'; #Code for Outlook 97 my $FolderName = "my shared folder"; my $strValidUser = "~ DSM Requests" ; #mailbox name/alias my $Outlook = Win32::OLE->GetActiveObject("Outlook.Application"); unless(defined($Outlook)){ die("Unable to obtain Outlook OLE handle $!\n"); } my $objNS = $Outlook->GetNamespace("MAPI"); my $objRecipient = $objNS->CreateRecipient($strValidUser); $objRecipient->Resolve(); #You should check this! my $objInbox = $objNS->GetSharedDefaultFolder($objRecipient, olFolder +Inbox); my $objFolder = $objInbox->Folders($FolderName); foreach my $email (in $objFolder->Items ){ if ($email->{UnRead} == 0) { #blah blah } }

    HTH - Mark

Re: Outlook & Win32::OLE
by bassplayer (Monsignor) on Aug 17, 2004 at 13:14 UTC
    Here's a node I wrote, which has some sample code that might help, but more importantly, you should check out Super Search, using Win32::OLE and Outlook as keywords. Quite a broad range of (hopefully) related nodes.

    bassplayer

      I am new to perl. I had a look at ur node, what does '-f' stand for in the statement
      unlink $temp_file_name if -f $temp_file_name;
      and what is '$|' variable?
        -f is a file test operator used to see if a file is plain text. In my code, I was just deleting the file if it existed, and probably should have used -e. More information on file test operators can be found here.

        As far as $|++, this stops the buffering of the output. $|=1 is cleaner in this case, so I've updated my old node. For more info on $|++ and $|=1, here are some interesting, relevant nodes.

        bassplayer

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-12-21 18:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (106 votes), past polls