我已使用下面链接中的此代码将 excel 文件作为附件发送。
http://www.hotscripts.com/forums/php/22626-php-form-excel-then-send-email-attachment.html
这是我使用的代码:
<?php
ob_start();
?>
<html>
<head><title></title>
</head>
<body>
<body>
<center>
<table>
<tr>
<td>Name:</td><td>My Name</td>
</tr>
<tr>
<td>Address:</td><td>My address</td>
</tr>
<tr>
<td>Gender:</td><td>Female</td>
</tr>
</table>
</body></html>
<?php
$FILE_CONTENTS = ob_get_contents();
ob_clean();
// include the class
include("../includes/classes/class.mailer.php");
$recipient = "myid@domain.com";
$from = "myid@domain.com";
// subject
$subject = "Subject of email";
// email message
$message = "
Here goes the message.
";
$myEmail = new EPDEV_Emailer($recipient, $from, $subject);
$myEmail->addText($message);
$myEmail->addFile("my.xls", "application/vnd.ms-excel", $FILE_CONTENTS);
$myEmail->send();
?>
我在邮件中收到 excel 文件,但该文件不包含正常 excel 文件包含的行。但我需要带有行的文件作为excel文件包含。谁能建议我可能是什么问题。
提前致谢