2011-12-07 40 views
2

你如何使用cfscript做以下操作?如何在CF9中使用cfscript發送附件的電子郵件?

<cfmail 
    from="[email protected]" 
    to="[email protected]" 
    subject="Attachments"> 
    <cfmailparam name="Reply-To" value="[email protected]"> 
    Some message goes here... 
    <cfmailparam file="c:\files\readme.txt"> 
    <cfmailparam file="c:\files\logo.gif"> 
</cfmail> 

使用以下導致「功能關鍵字缺少函數聲明中」錯誤:

mail subject="Test Email" from="[email protected] to="[email protected]" server="localhost" { 
    mailpart file="#ExpandPath('readme.txt')#"; 
} 

回答

7

這裏有一個如何對解釋需要做什麼:http://simonbingham.posterous.com/sending-email-using-cfscript-in-coldfusion-9

// Create an instance of the mail object 
mail=new mail(); 

// Set it's properties 
mail.setSubject("Sample Email"); 
mail.setTo("[email protected]"); 
mail.setFrom("[email protected]"); 
mail.setCC("[email protected]"); 
mail.setBCC("[email protected]"); 

// Add an attachment 
mail.addParam(file="C:\foo.txt"); 

// Add email body content in text and HTML formats 
mail.addPart(type="text", charset="utf-8", wraptext="72", body="This is a test message."); 
mail.addPart(type="html", charset="utf-8", body="<p>This is a test message.</p>"); 

// Send the email 
mail.send(); 
相關問題