Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Email from CGI Perl Script to MS Outlook

Status
Not open for further replies.

wsexton

Technical User
Dec 4, 2001
49
US
I'm trying to send email from a perl script to MS Outlook.

Here's my code:

use lib qw(lib);
use Mail::Outlook;

my $mail = new Mail::Outlook();
die "Cannot create mail object\n" unless $mail;

my $message = $mail->create();
die "Cannot create message object\n" unless $message;

$message->To('test@test.net');
#$message->Cc('Test <test@example.com>');
$message->XHeader('X-Header2','That');
$message->Subject('Blah Blah Blah');
$message->Body('Yadda Yadda Yadda');

my $status = $message->display;
print STDERR "message status was [$status]\n";
$message->send;

This works fine if I run it as a standalone perl script. If I embed it in another perl script it gives me the error message, 'Cannot Create Mail Object'. Any ideas why?
 
try

die "Cannot create message object\n$!\n" unless $message

which might give you an error that relates to what happened

Mike

You cannot really appreciate Dilbert unless you've read it in the
original Klingon.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Please note that 'XHeaders' are not supported by MS Outlook.

As to your problem, is this other script running from a CGI script? If so then the user that you are trying to access MS Outlook with may not be the same user as that for the command line script.

MS Outlook is very temperamental when it comes to being accessed by anything other than its own GUI. I've had problems before of having annoying popups with an automated script.

PS: Thanks for trying out my distribution :)

Barbie
Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top