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

Is there a way to use Perl on a Windows box to send mail through Microsoft's exchange mail server ?

Replies are listed 'Best First'.
Re: Exchange Mail
by Roger (Parson) on Sep 26, 2003 at 01:16 UTC
    To talk to the Microsoft exchange server, you need to use the MAPI interface. I have created an example below to send Email via exchange server:
    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!"; # Logon to server my $res = $session->Logon("roger", "letmepass"); die "Could not log on to exchange server!" if ($res); # Create a new message my $msg = $session->Outbox->Messages->Add(); # Add the recipient and resolve the address my $recipient = $msg->Recipients->Add(); $recipient->{Name} = "someone@somewhere.com"; $recipient->Resolve(); # Add your text $msg->{Subject} = "Email Test"; $msg->{Text} = qq/ Email test .... will this work? Regards Roger /; # Send the email $msg->Update(); $msg->Send(0, 0, 0); # Log off $session->Logoff();
    Hope this helps.

    Cheers, Roger.
Re: Exchange Mail
by hardburn (Abbot) on Sep 25, 2003 at 20:35 UTC

    As long as Exchange understands SMTP, there's no reason you can't use one of the multitude of Mail:: modules out there.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated