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

Hi, I have seen several articles of sending mail with attachments using the SMTP module. And I can do this with text files. But I have to send an excel attachment and the examples I have seen use other modules to achieve this. My problem is that the site I am working on is very locked down and anything new takes several months to be cleared. So does anyone have examples of using an excel file as an attachment with SMTP. Regards, John

Replies are listed 'Best First'.
Re: Net::SMTP with excel attachment
by Corion (Patriarch) on Jul 18, 2012 at 18:05 UTC
Re: Net::SMTP with excel attachment
by atcroft (Abbot) on Jul 19, 2012 at 07:05 UTC

    There may be better ways to do it, but I decided to pull out a script I used when testing a mail server and modify it to do what you described, within the restriction of trying not to use anything not listed as a core module. (Mostly I succeeded-the only exception would be if you require SMTP authentication, where you may need Authen::SASL and MIME::Base64.)

    The script creates valid headers, a plain text component with a list of files attached, and attaches each file as a UUEncoded attachment. It also allows you to specify the outgoing mail server/port, your credentials for SMTP authentication, sender, subject, multiple recipient addresses, a test mode to see what the output will look like, and an SMTP debug option to allow you to watch the SMTP transaction.

    Hope that helps.

Re: Net::SMTP with excel attachment
by zentara (Cardinal) on Jul 19, 2012 at 10:58 UTC