我試圖使用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是錯誤的,如果它是絕對路徑或相對路徑。另外'嚴格使用;' –