I am attempting to send an email containing an Excel report if data are
available. If no data are available the client should get a main stating
this.
No matter how I structure this I get: 'no data in this part'
I have attached a small script which demonstrates the problem.
If I build the MIME::Lite message and use:
ReadNow => 1,
I can make it work.
But I cannot get it to work the moment I separate out the attachment to
be controlled by the program flow.
I debugged so far I could see that Carp died on some UTF-8 problem, but
I am not sure what this relates to.
I am willing to do futher debugging if necessary I just want to make
sure I am not wasting my time on some misinterpretation of the docs on
my side.
I am a bit confused on when to use new directly and not build, but I
have tried both without success.
Thanks,
jonasbn
Subject: | mime-lite.pl |
#!/usr/bin/perl -w
use strict;
use Test::More qw(no_plan);
use Data::Dumper;
use MIME::Lite;
my $leads = $ARGV[0] || 0;
my $file = 'mime-lite.pl';
my $msg = MIME::Lite->new(
From =>'no-reply@telia.dk',
To => 'jonasbn@logicLAB.dk',
Type => 'TEXT',
Subject => "Leads: $leads from Dell",
);
if ($leads) {
$msg->attach(
Type => 'text/plain',
Path => "$file",
Disposition => 'attachment',
);
}
print STDERR Dumper $msg;
ok($msg->send('smtp', 'mail0.map.telia.dk', Timeout => 60));