sri1230 has asked for the wisdom of the Perl Monks concerning the following question:
Guys - I am trying to use some code posted by some one on this forums earlier and getting the folowing error when i try to run Can you pls help
No type library matching "Redemption.MAPIFolder" found at outlook_smtp +.pl line 6 Win32::OLE(0.1707): GetOleTypeLibObject() Not a Win32::OLE::TypeLib ob +ject at C: /Perl/lib/Win32/OLE/Const.pm line 49. Win32::OLE(0.1707) error 0x800401f3: "Invalid class string" at outlook +_smtp.pl l ine 20
#!/usr/bin/perl -w use strict; use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Outlook'; # set up Outlook OLE my $Outlook; eval {$Outlook = Win32::OLE->GetActiveObject('Outlook.Application')}; die "Outlook not installed" if $@; unless (defined $Outlook) { $Outlook = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit +;}) or die "Can't start Outlook: $!"; } my $ol = Win32::OLE::Const->Load($Outlook); my $namespace = $Outlook->GetNamespace("MAPI"); # select mailbox and folder my $mailboxname = "myMailbox"; # change this to the actual name of you +r mailbox my $foldername = 'Inbox'; # or whatever other folder you want to use my $ofolder = $namespace->Folders($mailboxname)->Folders($foldername) +|| die "Can't open folder Inbox: $!\n"; my $sfolder = new Win32::OLE("Redemption.MAPIFolder"); $sfolder->{'Item'} = $ofolder; # process messages my $n = $sfolder->Items->Count; my $sitem = new Win32::OLE("Redemption.SafeMailItem"); for (my $i=$n; $i>0; $i--) { $sitem->{'Item'} = $sfolder->Items($i); print "Subject: ",$sitem->{'Subject'},"\n"; # show sender as insured SMTP address my $sendaddrtype = $sitem->Fields(0xC1E001E); # hex key for SENDER +_ADDRTYPE my $senderemail; if ($sendaddrtype eq 'EX') { $senderemail = $sitem->{'Sender'}->Fields(0x39FE001E); # hex k +ey for EMAIL } else { $senderemail = $sitem->{'SenderEmailAddress'}; } print "\tSender: $senderemail\n"; # show recipients' SMTP addresses my $nrecip = $sitem->Recipients->Count; for my $j (1..$nrecip) { print "\tRecipient $j: ",$sitem->Recipients($j)->AddressEntry- +>SMTPAddress,"\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE question
by roboticus (Chancellor) on Jan 26, 2010 at 21:56 UTC | |
by sri1230 (Novice) on Jan 27, 2010 at 03:36 UTC | |
by Anonymous Monk on Jan 27, 2010 at 07:33 UTC |