如何在 CF9 中使用 cfscript 发送带有附件的电子邮件?

发布于 2024-12-20 06:05:50 字数 1125 浏览 4 评论 0原文

如何使用 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')#";
}

How do you do the following using 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>

Using the following causes a "function keyword is missing in FUNCTION declaration" error:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

献世佛 2024-12-27 06:05:50

以下是解释需要做什么的方法: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();

Here's a how-to explaining what needs to be done: 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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文