Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attaching a file to an email using CFFILE/CFMAIL

Status
Not open for further replies.

bamboo

Programmer
Joined
Aug 22, 2001
Messages
89
Location
US
I have a form that I created and want to include a field where they can attach a document to the outgoing email to the recipient. I have built many forms in which the FORM field information gets passed and emailed to the recipient, but I have never tried including a file. Any examples of how this is done.

Thanks much.
 
just use cfmailparam():
Description
Can either attach a file or add a header to a message. It is nested within a cfmail tag. You can use more than one cfmailparam tag within a cfmail tag.


Syntax
<cfmail
to = &quot;recipient&quot;
subject = &quot;msg_subject&quot;
from = &quot;sender&quot;
...more attibutes... >
<cfmailparam
file = &quot;file-name&quot; >
or
<cfmailparam
name = &quot;header-name&quot;
value = &quot;header-value&quot; >
...
</cfmail>
Sylvano
dsylvano@hotmail.com
 
Thanks. What I actually have is a form field where the user can hit 'browse' to select a file to include with the other information from the form. For instance they want to email me a powerpoint presentation attached to the email.

When you pass a regular form field it would 'FORM.email', etc. But what about the CFFILE input box on the form. After browsing and uploading the file, how do you pass that in the <CFMAIL> action page?
 
- the form field where user can select the file to attach is regular form element type=&quot;file&quot;;
- when user submits the form, with all the form information, he is in also uploading the file that you are going to attach to the email;
- once form is submitted, the uploaded file is also available on the server in the File collection; you can access the Uploaded file and attach it to the email by using:
<cfmailparam file = &quot;#file.serverfile#&quot;>
Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top