# POD-Dokumentation - siehe Dateiende! package User::InetMw::SendMail; use strict; use vars qw(@ISA @EXPORT $VERSION); use Exporter; $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw(&SendMail); sub _separator { return join ';', split /[ ,;]+/, shift; } use Win32::OLE; sub SendMail { my(%mail_props) = @_; return 'No Addressee to send mail to.' unless $mail_props{to}; my ($mail, $item); $mail = new Win32::OLE('Outlook.Application') and $item = $mail->CreateItem(0); # 0 = mail item. return 'Outlook is not running, cannot send mail.' unless $item; #$item->{From} = $mail_props{from} if $mail_props{from}; $item->{To} = _separator $mail_props{to}; $item->{Cc} = _separator $mail_props{cc} if $mail_props{cc}; $item->{Bcc} = _separator $mail_props{bcc} if $mail_props{bcc}; $item->{Importance} = ($mail_props{importance}) ? $mail_props{importance} : 1; # 2=high, 1=normal, 0=low $item->{Subject} = $mail_props{subject} || '[No Subject]'; $mail_props{body} =~ s/([^\n])$/$1\n/; $item->{Body} = $mail_props{body}; if ($mail_props{attachments}) { my $attach = $item->{Attachments}; foreach my $attach_file (@{$mail_props{attachments}}) { return 'No file indicated.' unless $attach_file; return "$attach_file isn't any file." unless -f $attach_file; $attach->add($attach_file); } } $item->Send() or return 'Send aborted.'; return 0; } 1; =head1 NAME User::InetMw:SendMail - Mails über Outlook senden =head1 SYNOPSIS use User::InetMw::SendMail; my $error = SendMail ( to => 'name@domain.de;name@domain.com', cc => 'ccname@domain.de', # optional bcc => 'bccname@domain.de', # optional importance => 1, # optional (2=high, 1=normal, 0=low) subject => 'subject', body => 'Mailtext', attachments => ['//host/dir/file.xxx'], ); =head1 DESCRIPTION Mails werden mit der Adresse des aktuellen Benutzers gesendet. Zwischen mehreren Mailadressen steht ';', ',', oder ' '. =head1 AUTHOR Steffen Winkler, 08.01.2003 =cut