With a little change, the CSV came through as an attachment.

use strict; use warnings; use Net::SMTP; my $msg = "foo"; my $subj = "my test subject"; my $csvfile = "opnet_ace_cap_agent_audit_$subj.csv"; my $boundary = 'frontier'; my $hostname = "myhost"; my @to = ( "user\@localhost" ); my @csv = ( "one line of csv", "another line of csv", ); my $smtp = Net::SMTP->new('smtp.somecorp.com', Timeout => 60); $smtp->mail( "root\@$hostname.somecorp.com" ); $smtp->to( @to); $smtp->data(); foreach my $dst ( @to ) { $smtp->datasend( "To: $dst\n" ) } # @to is a global (ducks for cover) $smtp->datasend("Subject: Opnet: Ace Capture Agent Audit: $subj\n"); $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-type: multipart/mixed; \n\tboundary=\"$bounda +ry\"\n"); $smtp->datasend("\n"); $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-type: text/plain\n"); $smtp->datasend("Content-Disposition: quoted-printable\n"); $smtp->datasend("\n$msg\n"); $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-Type: application/text; name=\"$csvfile\"\n") +; $smtp->datasend("Content-Disposition: attachment; filename=\"$csvfile\ +"\n"); $smtp->datasend("\n"); $smtp->datasend(\@csv); # Global array (ducks for cover again). $smtp->datasend("--$boundary--\n"); $smtp->dataend(); $smtp->quit;

update: it's not very good CSV content, but it did come through as an attachment.


In reply to Re^3: Problems sending an email attachment using Net::SMTP by ig
in thread Problems sending an email attachment using Net::SMTP by Argel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.