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

Hi, i was trying to send mail with excel(2003 version) attachment. But in the result mail the attachment is not visible in outlook 2003, people cant see the attachment. It is visible and people can open it in outlook 2007 through the same mail.Code below. Any idea why it is behaving like this?

use Mail::Sender; my $recipients = 'some@one.com'; my $sender = new Mail::Sender {smtp => 'smtp.com'}; if ($sender->OpenMultipart({from => 'some@one.com', to => $recipients +, cc =>'some@one.com', subject => "test", subtype => 'related', boundary => 'boundary-test-1', type => 'multipart/related'}) > 0) { $sender->Attach( {description => 'html body', ctype => 'text/html; charset=us-ascii', encoding => '7bit', disposition => 'NONE', file => "finalhtml.html" }); $sender->Attach( {description => 'ed\'s gif', ctype => 'application/vnd.ms-excel', encoding => 'base64', disposition => "inline; ", file => "some.xls" }); $sender->Close(1) or die "Close failed!$Mail::Sender::Error\n"; } else { die "Cannot send mail: $Mail::Sender::Error\n"; }

Replies are listed 'Best First'.
Re: Mail::Sender issue with attachment
by afoken (Chancellor) on Apr 24, 2012 at 17:39 UTC
    $sender->Attach( {description => 'ed\'s gif', ctype => 'application/vnd.ms-excel', encoding => 'base64', disposition => "inline; ", file => "some.xls" });

    The Content-Disposition header looks fishy. Excel files should be attached (C-D "attachment"), not inlined (C-D "inline"). The semicolon and the whitespace are at best useless, at worst, they confuse the recipient's mail client.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Thanks Alexander, i made those changes(disposition and semicolon & whitespace) but the same result. People who have 2003 outlook they cant even see the attachment. Is there something in the encoding part?

        Look at the mail source that is delivered to the mail server and check that the mail is constructed properly. Microsoft Software has a long history of ignoring or misinterpreting internet standards, so you should make sure that you feed Outlook with a properly formatted mail to avoid any Microsoft guesswork.

        I did not yet use Mail::Sender, but a quick scan of the documentation did not convince me to use it. Perhaps you could try MIME::Lite? It has its own set of minor problems, but I know that it reliably sends attachments that can be read by any MIME capable mail client.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Mail::Sender issue with attachment
by Jenda (Abbot) on Jul 17, 2012 at 07:55 UTC

    What if you change the "disposition" to 'attachment; filename="some.xls"; type="MS Excel"'?

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.