Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Mail::Outlook - it works but without attachment

by vagabonding electron (Hermit)
on Aug 13, 2012 at 11:35 UTC ( #987097=perlquestion: print w/ replies, xml ) Need Help??
vagabonding electron has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
it ought to be simple :-) - almost copied-and-pasted from the module documentation (script s. below).
It works, but the email comes without attachment.
The email is sent through MS Exchange Server if this matters.
What am I doing wrong?
Thanks in advance!
VE
#!/usr/bin/perl use strict; use warnings; use Mail::Outlook; use Win32::OLE::Const 'Microsoft Outlook'; my $outlook = new Mail::Outlook('Inbox'); my $file = "D:/TEMP/Text1.txt"; my $message = $outlook->create(); $message->To('me@mycompany.com'); $message->Subject('Test'); $message->Body('Test Message'); $message->Attach($file); $message->send;

Comment on Mail::Outlook - it works but without attachment
Download Code
Re: Mail::Outlook - it works but without attachment
by Anonymous Monk on Aug 13, 2012 at 11:50 UTC

    It works, but the email comes without attachment.

    What am I doing wrong?

    Are you authorized to send attachements?

    Try use Data::Dump; dd [ $message->display ]; , probably your *something here* is stripping the message

      Hi, Thanks a lot. How do we send HTML mail in this case?
Re: Mail::Outlook - it works but without attachment
by Anonymous Monk on Aug 13, 2012 at 11:56 UTC
    Also add  Win32::OLE->Option(Warn => 3); (or Warn => 2 )
      Thank you very much!
      It seems that Outlook did not see the network drive - as I changed the $file to "C:/Temp/Text.txt" the email came with the attachment.

      The dd [ $message->display ] produced [1] if the email came without attachment, in the last run (as email came with attachment) there were no output (I put the line as the last line in the script).
      The Win32::OLE->Option(Warn => 3); produced a message that an exception error in PROPERTYPUT "To" occured at the line 380 of Message.pm. This line deals with the "To" field ($self->{message}->{To}      = $self->{To}; ) and it occures even after the successful delivery of the email (with or without an attachment). I have just used my address to test the email.

      Thank you very much again!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://987097]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-12-22 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (113 votes), past polls