2

我正在使用 ColdFusion 文件,当用户从系统导出数据时,该文件将发送带有附件的电子邮件。目前,附件是 .txt 格式,难以解释,因此毫无帮助。我试图弄清楚如何更改此设置,以便电子邮件中发送的附件为 .csv 格式。这是我认为需要更改的代码部分:

    <cfset FileName = "#request.uncPath#\IncidentSummarySystem\data\" & #variable.UserName# & "-" &#DateFormat(now(), "ddmmyyyy")# & "-" & #TimeFormat(now(), "HHmmss")# & ".txt">  <cffile action="Write" file=#FileName# output="#FileData#">
<cfmail to="#rsUsers.qryUserEmail#" from="IncidentSummarySystem@" subject="Incident Summary System Export File" mimeattach="#FileName#">
    DO NOT REPLY TO THIS E-MAIL.
    Incident Summary System:  Your report is attached as a text (.txt) file.
</cfmail>
<script language="JavaScript">
    window.alert ("The information you have requested will be sent to you via e-mail.");
</script>
<cffile action="Delete" file="#FileName#">

是否可以将附件文件类型更改为 .csv,我将如何执行此操作?

4

1 回答 1

2

不是使用mimeattach,而是使用cfmailparam来附加文件。如果是带有.txt扩展名的简单 CSV 文件,请在创建时将其更改为 .csv。然后,在to的type属性中指定 mime-type 。cfmailparamapplication/vnd.ms-excel

<cfmail 
    to = "recipient"
    subject = "message subject"
    from = "sender"
        more attributes... >
    <cfmailparam 
        contentID = "content ID"
        disposition = "disposition type"
        file = "filename" 
        type ="media type">
    ...
</cfmail>
于 2014-09-02T21:25:22.967 回答