我试图使用Excel::Writer::XLSX
和MIME::Lite
发送附带xlsx文件的电子邮件。 excel文件的生成工作,因为我可以scp并在Excel中打开文件没有任何问题。当我试图从我的电子邮件客户端打开附件(Outlook 2013中)我得到这个错误:将xlsx附加到使用MIME :: Lite的电子邮件
"Excel cannot open the file "from_2014-06_to_2014-07.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
文件大小Outlook显示为444B,但它实际上是95K。我一直在使用Spreadsheet::WriteExcel
和MIME类型“application/vnd.ms-excel”发送xls文件,之前没有任何问题。
这是我试图发送电子邮件:
sub send_mail{
my $filename = shift;
my $to_email = shift;
my $from_email = shift;
my $date = shift;
$filename = shift;
my $mail = MIME::Lite->new(
'From' => '$from_email',
'To' => $to_email,
'Subject' => "Radio/TV stats $date",
'Type' => 'multipart/mixed',
#'content-type' => 'application/zip',
#'Data' => "Here is your stuff",
);
$mail->attach(
'Type' => 'TEXT',
'Data' => "Here is your stuff",
);
$mail->attach(
#'Type' => 'application/vnd.ms-excel',
'Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Path' => $filepath,
'Filename' => $filename,
'Disposition' => 'attachement',
);
$mail->send('sendmail');
}
任何人都可以请帮我附上XLSX文件?
尝试“数据”=>“文件大小:”。 -s $ filepath' –
'Data'=>“文件大小”。 -s $文件路径返回0. ls -la返回97403.此外,该附件仍然不起作用。 – Twistar
所以$ filepath是错误的,如果它是绝对路径或相对路径。另外'严格使用;' –