> -----Original Message-----
> From: Richard DeWath [mailto:[EMAIL PROTECTED] 
> Subject: Reading Mail from Exchange Folder

> I am just learning about this and need some pointers
> on how I can write a Perl script that lets me read my
> new mail on an Exchange server [assume the Inbox],
> find mail with a fixed subject I am looking for, then
> process the data, move the mail to a "read" folder. 
> Any good examples, pointers or books that will let me
> do this using Activestate Perl for Windows?

Assuming you have outlook, this should get you started:

<code>
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';

$Win32::OLE::Warn = 2; # Throw Errors, I'll catch them
my $outfile = 'c:\perl\projects\improvdb\nahatemailssorted.txt';
my $OL = Win32::OLE->GetActiveObject('Outlook.Application')  or die
Win32::OLE->LastError();

my $NameSpace = $OL->GetNameSpace("MAPI");
my $Folder = $NameSpace->GetDefaultFolder(olFolderInbox);
    
   foreach my $msg (in $Folder->{Items}){
       if ($msg->{Subject} =~ m/<REGEX GOES HERE>/i)
       {
           #Here, there be move code
       }
   }
</code>

Also, I wrote a tutorial on using Excel and Win32::OLE on perlmonks, but the
beginning portion is applicable to all Win32::OLE use, and is worth the
read.

http://perlmonks.org/index.pl?node_id=153486

Otherwise, using Win32::MAPI would also be a choice.

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**********************
** LEGAL DISCLAIMER **
**********************

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to