line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::EmailSend;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22999
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
423
|
use Win32::OLE;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.04';
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN {
|
10
|
|
|
|
|
|
|
use Exporter;
|
11
|
|
|
|
|
|
|
our @ISA = qw( Exporter );
|
12
|
|
|
|
|
|
|
our @EXPORT = qw( );
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( );
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw( &SendIt );
|
15
|
|
|
|
|
|
|
}
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub SendIt($;$$;$$$;$$$$) {
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $to = shift;
|
20
|
|
|
|
|
|
|
my $cc = shift;
|
21
|
|
|
|
|
|
|
my $subject = shift;
|
22
|
|
|
|
|
|
|
my $body = shift;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
defined $to or $to = "";
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
($to) or die "USAGE: $0\n <\"To\">\n [<\"Cc\">]\n [<\"Subject\">]\n [<\"Body\">]\n [<\"Attachment 1\">]\n [<\"Attachment 2\">]\n [<\"Attachment ...\">]\n";
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $email = Win32::OLE->new('Outlook.Application') or die $!;
|
29
|
|
|
|
|
|
|
my $items = $email->CreateItem(0) or die $!;
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$items->{'To'} = $to;
|
32
|
|
|
|
|
|
|
$items->{'CC'} = $cc;
|
33
|
|
|
|
|
|
|
$items->{'Subject'} = $subject;
|
34
|
|
|
|
|
|
|
$items->{'Body'} = $body;
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
foreach my $attach (@ARGV) {
|
37
|
|
|
|
|
|
|
die $! if not -e $attach;
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $attachments = $items->Attachments();
|
40
|
|
|
|
|
|
|
$attachments->Add($attach);
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} # foreach
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$items->Send();
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $error = Win32::OLE->LastError();
|
47
|
|
|
|
|
|
|
print "Email ok.\n" if not $error;
|
48
|
|
|
|
|
|
|
print "Email ko.\n" if $error;
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} # SendIt
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1;
|
53
|
|
|
|
|
|
|
__END__
|