我花了几天时间将send csv发送到没有附件的电子邮件。从mysql表中获取结果并将其打印在html表中,并将其定义为该动态表的$ message。
PHP:
$message='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div style="margin-bottom: 20px;">
<div style="height: 45px; width: 100%; padding-bottom: 50px;">
</div>
<div>
<table style="border-collapse: collapse;" border="1">
<tr style="background: #D9E9FC repeat-x top;">
<th style="background:#2D71BF repeat-x top; color:#fff; font-size: 13px;text-align: left; padding: 8px;">EmpCode</th>
<th style="background:#2D71BF repeat-x top; color:#fff; font-size: 13px;text-align: left; padding: 8px;">Role</th>
<th style="background:#2D71BF repeat-x top; color:#fff; font-size: 13px;text-align: left; padding: 8px;">EmpName</th>
</tr>
$selectQuery="select * from mall_email_escalation where lead_id!='' and reports_to!='' limit 0,10";
$resultSet=mysql_query($selectQuery);
while($row = mysql_fetch_assoc($resultSet))
{
$message .= '
<tr>
<td>'.$row['fg_emp_code'].'</td>
<td>'.$row['fg_emp_role'].'</td>
<td>'.$row['fg_emp_name'].'</td>\
</tr>
}
$message .= '
</table>
</div>
</div>
</body>
</html>';
我能够以html格式发送$ message。但我想以csv格式发送此$ message。请帮助我。
此致 Nandhagopal.J