#!/usr/bin/perl -w use strict; use warnings; use POSIX; use Win32::OLE; open SOURCE, "< //reports/test.txt"; my $procdate = POSIX::strftime('%m/%d/%Y %H:%M', localtime); my @ies_details; my $Outlook = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application'); #$Outlook = new Win32::OLE('Outlook.Application'); while() { my $source = $_; next if ($source =~ m/^(\s)*$/); next unless (substr($source,11,4) =~ m/(\d){4}/); if (substr($source,79,10) =~ /(\d){10}/) { push @ies_details,$source; } } my $test; foreach (@ies_details) { $test = $test . $_; }; my $mailitem = $Outlook->CreateItem(0); #Create mail Item unless ($mailitem) {die "Outlook is not running, cannot send mail.\n";} $mailitem->{'To'} = 'test@yahoo.com'; $mailitem->{'Cc'} = 'test@test.com'; $mailitem->{'Subject'} = 'Summary Report ' . $procdate; $mailitem->{'Body'} = 'Below is a summary.' . "\n\n" . '-----------------------------------------' . "\n\n" . $test; $mailitem->{'Importance'} = 0; # 2=high, 1=normal, 0=low $mailitem->Send;