use strict; use warnings; use Win32::OLE; my $oa; eval {$oa = Win32::OLE->GetActiveObject('Outlook.Application')}; die "Outlook not installed" if $@; unless (defined $oa) { print "Outlook is not running. Attempting to start it.\n"; $oa = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Outlook"; } # do something with $oa here