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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFMail with attachment error

Status
Not open for further replies.

Chloeee

Programmer
Jan 16, 2001
27
0
0
US
The goal is simple. Allow a user to fill out a form, browse for a file, and submit the form. The info is received by a template which e-mails the form data with the file attached.

The e-mail and info sends fine, but when I try to use either mimeattach or cfmailparam to attach the file, I get the following error from my browser:

Unable to attach file.

Cannot attach 'C:\DATA\Backup Webs\scoutdoors\images\bigshot.jpg' to the mail message. The file does not exist.

This happens with any file I try to attach and with both mimeattach and cfmailparam tags. Any help is appreciated as I really don't know what else to try.

 
HELLO

This might be silly but I see a space in your path name, is that actually supposed to be there? If so it might need to be translated. I believe the correct translation for a space in a URL is %20 but I'm not possitive.

'C:\DATA\Backup Webs\scoutdoors\images\bigshot.jpg'

hope it helps. Otherwise post your code and lets have a look at it.
 
Hey thanks for taking this on. I did have a space in the directory on my harddrive. When I removed it, however, I got the same error. The sending template 1 and receiving template 2 code is listed below. The current URL for the page is if you'd like to try to attach for yourself. There is a funky CF tag that runs 3 of the SELECT boxes and inserts some JavaScript. Could that be interferring somehow?

template 1: (minus the table garbage and other field info)
Code:
<cfform action=&quot;list_request_send.cfm&quot; method=&quot;POST&quot; name=&quot;list_request&quot;>
<div align=&quot;right&quot;>Logo:</div>
<input type=&quot;file&quot; name=&quot;Image&quot; size=&quot;45&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Send Request&quot; class=&quot;button&quot;>

template 2:
Code:
<!--- Begin Send Listing Request --->
<cfmail to=&quot;valerie@suresource.net&quot; from=&quot;valerie@suresource.net&quot; subject=&quot;Listing Request from Website&quot;>
<cfmailparam file=&quot;#Form.Image#&quot;>
Listing Request from SCOutdoors.com

========= Contact Information =========
Name: #ContactName#
E-Mail: #ContactEmail#
Phone: #ContactPhone#

========= Listing Information =========
This contact #Preferred# interested in more information about a preferred listing.

Company Name: #BizName#
Phone: #BizPhone#
Website Address: #Link#
Description: #Description#
Specialty: #Specialty#
Type: #Type#
Area: #Area#
<cfif image is not &quot;&quot;>
A logo is attached
<cfelse>
No logo was submitted
</cfif>
</cfmail>
<!--- End Send Listing Request --->
 
Hey Chloeee,

When you're attempting to upload a file via a form submission, your <form> tag must have the encType=&quot;multipart/form-data&quot; attribute. Also, you don't show the code for the <cffile action=&quot;upload&quot;...> which is required to receive the file and write it to your hard drive. Once <cffile> does this, you can access the file by its true name on the server with #cffile.serverFile# and not #form.image#.

Hope this helps,
GJ
 
I need the file to attach to the email being sent, not write itself to the server. Do I need to incorporate an upload somehow with the mimeattach or cfmailparam?
 
Unless they've changed <cfmail> with 4.5, you can't send the file straight to <cfmail> as <cfmail> looks for a file on the server's hard disk. You'll need to use <cffile> to upload and then <cfmail> to attach the file where <cffile> left it. You'll probably want to then do a <cffile action=&quot;delete&quot;...> to remove it after you've mailed it.

GJ
 
Ahhh... very cool. I'm sure that will do it. I wonder why they didn't say in the docs or in my manual. *sigh* Thank you so much. I'll let you know Monday if it was a no go on that. Enjoy the weekend!
 


Sorry I didn't get back to you on that Chloeee, I was out for the morning looks like GunJack gave you the run down on the mail atatchment though.


 
This worked BEAUTIFULLY! Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top