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

#!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

In reply to Email on Win32, MSExchange by Zo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.