muckv has asked for the wisdom of the Perl Monks concerning the following question:

Hey guys, i'm trying to add some extra functionality to a little program I wrote (perl first timer). I want to open a "new mail" outlook window with an attachment in it.
What follows is a little code snippet I found on the net. I edited this a bit but can't seem to add the attachment to the mail window.
The code opens the new mail window but there is no attachment in it.
It should contain a pdf doc located in the same folder as the script.
How can I add the attachment to the new mail windows?
The cpan documentation isn't really clear to me
http://search.cpan.org/~barbie/Mail-Outlook-0.15/lib/Mail/Outlook/Message.pm Thanks for the input
use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Outlook'; @attachments = ("output.pdf"); my $Outlook = Win32::OLE->GetActiveObject ('Outlook.Application') || Win32::OLE->new('Outlook.Application'); my $Outlook = new Win32::OLE('Outlook.Application'); # Create Mail Item my $item = $Outlook->CreateItem(0); # 0 = mail item. $attach = $item->{'Attachments'}; $attach->add(@attachments); $item->display();

Replies are listed 'Best First'.
Re: WIN32:OLE insert attachment into mail object
by Anonymous Monk on Jun 08, 2009 at 14:50 UTC
      I tried but I can't figure it out, the created mail window does not contain the attachment