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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Mail with Outlook
by hopes (Friar) on Dec 13, 2001 at 15:30 UTC | |
by jgamble (Pilgrim) on Jan 19, 2002 at 09:26 UTC | |
Re: Mail with Outlook
by encode (Initiate) on Dec 13, 2001 at 11:01 UTC | |
by perlmoth (Hermit) on Dec 13, 2001 at 14:28 UTC |