Gerard has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, just getting started with this one, and didn't know where so I had a look around the monastery. I found the following node, How do I send E-mail via Microsoft exchange server from my Perl Program? and just copy / pasted the code.
I modified it slightly for trouble shooting, and so I would be able to logon ok...
use Win32::OLE; use strict; # Create a new MAPI session my $session = Win32::OLE->new("MAPI.Session") or die "Failed to create a new MAPI Session! " . $!;
Are the first few lines, and that is where it is dying, with the following error message.
C:\Documents and Settings\GO\Desktop>test.pl Failed to create a new MAPI Session! Bad file descriptor at C:\Documen +ts and Set tings\GO\Desktop\test.pl line 5.
Using windows 2k professional, and perl v5.8.1.

I have never tried to do this before and so am a bit stumped.
Any ideas much appreciated.
Regards,

Gerard

Replies are listed 'Best First'.
Re: Sending Email via Exchange
by tachyon (Chancellor) on Dec 02, 2003 at 21:59 UTC

    M$ more or less killed MAPI access from all external programs to fix their virus/worm/trojan/whatever you wanna call em problems with one of their service packs. I forget which but it was irreversible, quite a while ago and you will almost certainly have installed it. They broke all sorts of MAPI dependent stuff and caused a lot of grief.

    They call it 'trusted code control'. Definition of trusted == written by M$. Anyway, these days to use MAPI from ANY non M$ (ie external programs like VB or Perl OLE) requires special patches to Exchange, and you must be delevering all mail to Exchange mailboxes or OST or the patches don't work. We were using some PSTs so......

    See http://www.microsoft.com/office/ork/xp/four/outg03.htm and Google for 'Microsoft breaks MAPI access with service pack' for all the gory details.

    PS We gave up on trying to make it work and ported code to sending mail without using MAPI....

    cheers

    tachyon

      Thanks heaps for the info... looks like it is back to net::smtp and net::dns.

      Regards,
      Gerard

        Unless you need it (ie wenna do it in VB) that is the path of least resistence.

        cheers

        tachyon

Re: Sending Email via Exchange
by inman (Curate) on Dec 03, 2003 at 10:55 UTC
    If all that you want to do is send e-mail, just use Exchange as if it were a normal SMTP server and use a module such as Mail::Sender to construct and send the mail. The implementation is all in Perl so there are no OLE related complications.

    This method should work equally well regardless of whether your mail system is based on Exchange, Lotus Notes, Sendmail etc. I make extensive use of this module to send e-mail via our Lotus Notes infrastructure.

    inman