http://qs321.pair.com?node_id=294326

Roger has asked for the wisdom of the Perl Monks concerning the following question: (mail and news)

How do I send E-mail via the Microsoft exchange server?

Originally posted as a Categorized Question.

  • Comment on How do I send E-mail via the Microsoft exchange server?

Replies are listed 'Best First'.
Re: How do I send E-mail via Microsoft exchange server from my Perl Program?
by Roger (Parson) on Sep 26, 2003 at 07:01 UTC
    To send E-mail via 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();

      OK... cool... then, how do you add an attachment? --lnl