只需添加
destination
属性,然后将该路径用于邮件。
<cfset filePath = GetTempDirectory() & "emailfile.pdf">
<cfhtmltopdf destination="#filePath#" orientation="portrait" pagetype="A4" margintop="1" marginbottom="1" marginleft="1" >
<html>
<head>
</head>
<body>
<table>
<tr>
<th>Test1</th>
<th>Test2</th>
<th>Test3</th>
</tr>
<tr>
<td>ABC</td>
<td>ABC</td>
<td>ABC</td>
</tr>
</table>
</body>
</html>
</cfhtmltopdf>
<cfmail to="..." .... >
<cfmailparam file="#filePath#" disposition="attachment" type="#fileGetMimeType(filePath)#" remove="true">
<cfmailpart type="html">Content</cfmailpart>
</cfmail>