Zo has asked for the wisdom of the Perl Monks concerning the following question:
This is probably a very simple question or problem, but so far I've been going well and I need some extra eyes to guide me. I get an error at the 'Logon'. Here is the posted code.
Perl 5.06.., on Win2000 Server
Any help? Is this something simple I'm overlooking? I have sent email from my desktop with the working function in my code 'send_outlook_mail', but was trying to do it from one of our servers. So I went to www.deja.com and other sites to get help/information. I took the info from the MAPI connection and worked it around my send_outlook_mail function, knowing that the email sending works on my pc here. Thought if I made the connection on the server via MAPI in windows this could work. Is my thought on this and code way off?
Thank you all in advance for any/all help.
.Zo
Perl 5.06.., on Win2000 Server
#!perl use Win32::OLE; use OLE; my $MAPISession = CreateObject OLE "MAPI.Session" || die; $MAPISession->Logon('servername','password'); #### ####this is where it fails ^ #### $newfile = "./perl_test.txt"; open(BATCH, ">>$newfile") || die "Can't open $newfile : the perl_test. +txt file. $!"; ################## sub send_outlook_mail { #use OLE and Outlook to send an email message my $to = ("me\@myemail.com"); my $subject ="DB connection failure"; # my $body = "The connection failed.\n"; # my $cc = shift; # my $cc = ("you\@youremail.com"); #get new Outlook instance my $mail = new Win32::OLE('Outlook.Application') || die "Unable to + start Outlook instance: $!"; my $item = $mail->CreateItem(0) || die "Unable to create mail item +: $!"; $item->{'To'} = $to; # $item->{'CC'} = $cc; $item->{'Subject'} = $subject; # $item->{'Body'} = $body; #rest of args are file attachments foreach my $attach (@ARGV) { # print STDERR "File attachment: $attach\n"; #make sure the attachment is really there # croak "Missing attachment $attach: $!" if !-e $attach; # my $attachments = $item->Attachments(); # $attachments->Add(); } $item->Send(); my $error = Win32::OLE->LastError(); #carp "Win32::OLE error: $error" if $error; } #sub send_outlook_mail ################ $time = `Time /T`; print BATCH $xx." ".$time; send_outlook_mail(); $MAPISession->Logoff(); # close new .txt file close (BATCH);
Any help? Is this something simple I'm overlooking? I have sent email from my desktop with the working function in my code 'send_outlook_mail', but was trying to do it from one of our servers. So I went to www.deja.com and other sites to get help/information. I took the info from the MAPI connection and worked it around my send_outlook_mail function, knowing that the email sending works on my pc here. Thought if I made the connection on the server via MAPI in windows this could work. Is my thought on this and code way off?
Thank you all in advance for any/all help.
.Zo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Email on Win32, MSExchange
by gav^ (Curate) on Mar 06, 2002 at 17:15 UTC | |
Re: Email on Win32, MSExchange
by strat (Canon) on Mar 06, 2002 at 17:12 UTC | |
Re: Email on Win32, MSExchange
by grummerX (Pilgrim) on Mar 06, 2002 at 18:26 UTC |
Back to
Seekers of Perl Wisdom