Hosting Software News & Commentary Hosting Software News & Commentary Hosting Software News & Commentary

The following Perl script is called by the Outlook macro in the previous post Making Outlook talk to Perl: Part one: VBA side. It takes all the attachments from the mail and puts them in a directory on the desktop.

; exit;}# Print an error message, and die if the second argument is true.sub err{ my ($errmsg, $quit) = @_; print $errmsg, “\n”; wait_quit if ($quit);}my $subject;my $job_number;if (@ARGV) { $subject = join (’ ‘, @ARGV); if ($subject =~ /\(Job:(\d+)\)/) {$job_number = $1; } else {err (”The current mail subject $subject is not \”Job\”.”,1); }} else { err (”No command line given. Quitting!”, 1);}# Connect to Outlook.my $Outlook = || ‘Quit’) or err “Could not connect to outlook”, 1;# The currently selected message.my $message = Check that the command line and the Outlook mail have the same subjects.if ($message) { my $msubject = $message->Subject; if ($msubject ne $subject) {my $moan=<differs from the subject<$msubject>of the currently selected mail message in Outlook.endmoanerr ($moan); }}# Location of desktop.my $desktop = ‘C:/Documents and Settings/bkb/Desktop/’;# Create directory to save attachments to.my $jobdir = $desktop.$job_number;if (-d $jobdir) { err (”There is already a directory for job $job_number.”);} else { if (!mkdir $jobdir) {print “Error making $jobdir: $!”;wait_quit; }}# Get the number of attachments.my $n_attach = $message->Attachments->Count;# Save all the attachments into the directory created above.for (my $i=1;$iAttachments->Item($i); $attach->SaveAsFile

  1. No user reviews yet.


Leave a Reply





Blogroll