You use the cfmailparam
tag to include files in your message or add a custom header to an e-mail message. You can send files as attachments or display them inline in the message. You nest the cfmailparam
tag within the cfmail
tag.
You can use one cfmailparam
tag for each attachment, as the following example shows:
<cfmail
from="[email protected]" to="[email protected]" subject="Requested Files"> Jake, Here are the files you requested. Regards, Dan <cfmailparam file="c:\widget_launch\photo_01.jpg"> <cfmailparam file="c:\widget_launch\press_release.doc"> </cfmail
>
You must use a fully qualified system path for the file
attribute of cfmailparam
. The file must be located on a drive on the ColdFusion server machine (or a location on the local network), not the browser machine.
You can use the cfmailparam
to include images from other files in an HTML message, as follows:
cfmailparam
tag for each image following the cfmail
start tag.
cfmailparam
tag, do the following
file
attribute to the location of the image.disposition="inline"
contentID
attribute to a unique identifier; for example, myImage1.img
tag such as the following:
<img src="cid:myImage1">
The following example shows a simple mail message with an inline image. In this case, the image is located between paragraphs, but you could include it directly inline with the text. To test this example, replace the cfmail
to
parameter with a valid email address and change the file
parameter to the path to a valid image.
<cfmail type="HTML" to = "[email protected]" from = "[email protected]" subject = "Sample inline image"> <cfmailparam file="C:\Inetpub\wwwroot\web.gif" disposition="inline" contentID="image1"> <P>There should be an image here</p> <img src="cid:image1"> <p> This text follows the picture</p> </cfmail>
When the recipient of an e-mail message replies to the message, the reply is sent, by default, to the address specified in the From field of the original message. You can use cfmailparam
to provide a Reply-To e-mail address that tells the mail client to override the value in the From field. Using cfmailparam
, the reply to the following example is addressed to [email protected]:
<cfmail
from="[email protected]" to="[email protected]" subject="Requested Files"><cfmailparam name="Reply-To" value="[email protected]">
Dan,
Thanks very much for the sending the widget press release and graphic.
I'm now the company's Widget Master and am accepting e-mail at
[email protected].
See you at Widget World 2002!
Jake
</cfmail>
Note: You can combine the two uses of cfmailparam
within the same ColdFusion page. Write a separate cfmailparam
tag for each header and for each attached file.