What do you mean by "good way"? There are allways more ways to do it...
If the above code works, it works. Not that there are things to improve; for example, you fill an array, which you later join. Why not join the lines directly?A (slightly rewriten) version of your code could be:
#!/usr/bin/perl use strict; use warnings; use POSIX; use Win32::OLE; open my $source, "<", "//reports/test.txt" or die "cannot open file: $!\n"; my $ies_details; while( <$source> ) { next unless substr $source,11,4 =~ /\d{4}/; next unless substr $source,79,10 =~ /\d{10}/; $ies_details .= $_; } my $Outlook = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application'); my $mailitem = $Outlook->CreateItem(0) or die "Outlook is not running, cannot send mail.\n"; my $procdate = POSIX::strftime('%m/%d/%Y %H:%M', localtime); $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" . $ies_details; $mailitem->{'Importance'} = 0; # 2=high, 1=normal, 0=low $mailitem->Send;
Paul
In reply to Re: Add Results to Outlook body
by rev_1318
in thread Add Results to Outlook body
by drodinthe559
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |