Thanks to the code written in various Q&A sections, i wrote my own function to send mail using Outlook. This function uses Win32::OLE (of course), and returns 0 on failure and 1 for success. It does *not* open or close Outlook, which was outside the scope of the function - you can open or close it yourself in the calling code. I'll follow up with a similar function that uses the CDONTS lib instead of Outlook.
sub outlook_mailer { my(%mail_props) = @_; unless (exists $mail_props{'to'} and defined $mail_props{'to'}) { carp "No Addressee to send mail to.\n"; return 0; } my $mail = new Win32::OLE('Outlook.Application'); my $item = $mail->CreateItem(0); # 0 = mail item. unless ($item) { carp "Outlook is not running, cannot send mail.\n"; return 0; } $item->{'Subject'} = $mail_props{'subject'} || '[No Subject]'; $item->{'To'} = join(";", split(/[ ,;]+/, $mail_props{'to'})); $item->{'Body'} = $mail_props{'body'} || "\r\n"; $item->{'From'} = $mail_props{'from'} if (exists $mail_props{'from'} +); $item->{'Cc'} = $mail_props{'cc'} if (exists $mail_props{'cc'}); $item->{'Bcc'} = $mail_props{'bcc'} if (exists $mail_props{'bcc'}); $item->{'Importance'} = (exists $mail_props{'importance'})? $mail_props{'importance'}: 1; # 2=high, 1=normal, 0=low if (exists $mail_props{'attachments'}) { my $attach = $item->{'Attachments'}; foreach my $attach_file (@{ $mail_props{'attachments'} }) { if ($attach_file and -f $attach_file) { $attach->add($attach_file); } } } $item->Send(); return 1; }

In reply to Mail with Outlook by jgamble

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.