evergreean43
Technical User
I need to create a Perl script that will run on my local Windows 2000 workstation once a day and find in my Outlook 2003 Office Email the Subject: Journal. Then take the message from the email Journal and populate a text file with the message information.
Is this the right direction? I seem to get errors on my attempt:
Is this the right direction? I seem to get errors on my attempt:
Code:
use strict;
use warnings;
use Win32::OLE 'in';
use Win32::OLE::Const 'Microsoft Outlook';
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';
open (REPORT, ">file.txt")||die "Can't open report file!\n";
while ($line = <REPORT>) {
print "$line\n"; #
}
close (REPORT);
}
}