Mail attachment using perl Hello All, My script collects information and writes it to a xls file and should mail it across. I tested the first part of the script which writes the excel file , it does write the excel file fairly with expected data using Spreadsheet::WriteExcel module Second part uses MIME::Lite , All I get is a mail with intended subject intact but without the attachment . Following is the code , I have googled and tried out many options , didn't go any further apart from receiving a mail without attachment. use MIME::Lite; $msg = MIME::Lite->new( From => 'xx', To => 'xx', Subject => 'using module' ); $msg->attach( Type => 'application/xls', Encoding => 'base64', ); $msg->attach( Path => '/tmp/hello.xls', Filename => 'hello.xls', Disposition => 'attachment' ); $msg->send(); I am using RHEL 4 , Perl 5.8 Kindly advise me of what might be going wrong . Thanks in Advance. Last edited by ++nick++; 02-28-2010 at 01:41 PM. | |
Quote:
... I haven't read the documentation, but are you sure you have to call the 'attach' method twice ? And are you sure the return value of the 'attach' method shouldn't be checked for errors ? Last edited by Sergei Steshenko; 03-01-2010 at 05:25 AM. | |
|
Thanks for the reply, I tried to mail a plain text file , it didnt work either , all I received is a mail without attachment , below is the code, use MIME::Lite; $mail = MIME::Lite->new( From => 'xx', To => 'xx', Subject => 'mailing a text attachment using mime lite', ); $mail -> attach( Type => 'text/html', Path => '<absolute path>', Filename => 'file1', Disposition => 'inline', ); $mail -> send(); #END Kindly advice |
|
Try this Hello nick, Try the following code. Code: use strict;use warnings;use MIME::Lite;my $msg = MIME::Lite->new( From => 'xxx', To => 'xxx', Subject => ' Test message', Type => 'multipart/mixed',);$msg->attach( Type => 'text', Data => "Here is the file",);$msg->attach( Type => 'text', Path => '/home/user/Documents/Assignment1', Filename => 'Assignment1',);$msg->send; Thanks. Last edited by karthi_27; 03-01-2010 at 05:15 AM. |
|
Hello All, Adding a line(Type => 'multipart/mixed',) to the code made all the difference , fine the code below , use MIME::Lite; $mail = MIME::Lite->new( From => 'ramkar', To => 'ramkar', Subject => 'mailing a text attachment using mime lite', Type => 'multipart/mixed', ); $mail -> attach( Type => 'text/html', Path => '/ms/user/r/ramkar/file1', Filename => 'file1', Disposition => 'attachment', ); $mail -> send(); #END Thanks All. |
|
Hi, Thanks karthi , I saw your post only after posting mine in which i expressed the need for mentioning Type , thanks anyways Cheers |
联系客服