in reply to Re: Problems sending an email attachment using Net::SMTP
in thread Problems sending an email attachment using Net::SMTP

Did it come through with the CSV file as an attachment? The output I pasted in is from the email my hotmail account received (from the view message source option) so all of the text is making it through but the whole multipart aspect is broken.

get_datetime() produces output like: 2009_06_26_21-35-37 so I don't think it would be causing a problem.

Elda Taluta; Sarks Sark; Ark Arks

  • Comment on Re^2: Problems sending an email attachment using Net::SMTP

Replies are listed 'Best First'.
Re^3: Problems sending an email attachment using Net::SMTP
by ig (Vicar) on Jun 27, 2009 at 07:45 UTC

    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.

      Thanks ig!! As I indicated in my OP, your changes did the trick. I really appreciate the help!!

      Elda Taluta; Sarks Sark; Ark Arks