這裏發送的.xls作爲附件Perl是發送電子郵件的代碼:使用了Email :: MIME
use Email::MIME;
use IO::All;
my @parts = (
Email::MIME->create(
attributes => {
filename => "report.xls",
content_type => "application/vnd.ms-excel",
encoding => "base64",
},
body => "Body added as per the answer to this question" #no effect
),
Email::MIME->create(
attributes => {
content_type => "text/plain",
charset => "US-ASCII",
encoding => "base64",
},
body_str => "$body_of_message",
),
);
use Email::Send;
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host => 'localhost']);
$sender->send($email);
現在我能夠發送郵件和,但report.xls
是空的,即0字節。它出現在我的本地目錄中,我無法理解爲什麼它不被當作附件。我也嘗試給絕對路徑,但那不起作用。