I am trying to create a mail using Mail::Outlook
. I followed this answers I believe is correct:
Sending email using Perl
Mail::Outlook CPAN
I created a simple code based from the tutorials:
use strict;
use warnings;
use Mail::Outlook;
use Data::Dumper;
my $outlook = new Mail::Outlook();
print Dumper($outlook);
print Dumper(Win32::OLE->LastError()); #added in response to comment
my $message = $outlook->create();
$message->To('sample@gmail.com');
$message->Cc('another@gmail.com');
$message->Subject('Testing sending mail from perl');
$message->Body('Hi, This is the body! wahahah!');
$message->save();
1;
The emails I used are real but I replaced it here for privacy's sake.. When I run the script, an error appeared:
$VAR1 = undef;
Can't call method "create" on an undefined value at send_mail.pl line 14.
It seems that the variable $outlook
did not initialized during new Mail::Outlook()
. The module Mail::Outlook returns undef
if initiating a new object failed.. Now, I wonder why this happened.. I am thinking it was because of security issues of outlook but I don't know how to tweak that. Please perl masters out there, if anyone has the same experience or have encountered this, it would be helpful..
I am using Microsoft Outlook 2007 in windows 7 and I installed ppm install Mail-Outlook
.
My main question is: How can I create a mail using Mail::Outlook in Outlook 2007
UPDATE
I tried using print Dumper(Win32::OLE->LastError());
and it printed this error:
$VAR1 = 'Win32::OLE(0.1709) error 0x80080005: "Server execution failed"';