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

path to attach a file with cfmail 2

Status
Not open for further replies.

Pepote

Programmer
Dec 20, 2000
4
MX
I have a form to send messages with cfmail to a mailing list, the problem is when I create a field to attach a file to that mailing list, because can´t find the file. The file is in the same´s form directory, but altough I put the path the error I get is that can´t find the file.
Can anyone helpme to solve the problem??
Thanks
 
I'm afraid I don't quite understand your problem. Are you trying to use a form to upload a file that gets mailed or do you need cfmail to send a file that resides on the server? If you are sending a file from the server and it's in the same directory as the script with cfmail, this should do what you want where "MyFile.txt" is the file you're sending.

<cfmail
to=&quot;yourAddress@yahoo.com&quot;
from=&quot;yourAddress@yahoo.com&quot;
subject=&quot;File&quot;
mimeattach=&quot;#getdirectoryfrompath(cgi.path_translated)#\MyFile.txt&quot;
>
Message Here
</cfmail>

GJ
 
Le me be more specific. I have a form, this form sends simple messages to an email, obtained from a query, and it works fine. the problem comes when a insert a field in the form to input the path of a file to attach with the message, when I send the form CF server gives me the next error:
&quot;unable to attach file, Cannot attach the file &quot;myfile.txt&quot; to the mail message. the file does not exist&quot;

I know the file must be on the cfserver to be sent, but I can´t send it. let me know if I explained better
 
I think I understand now. You have a regular text box where you're typing the name of the file to send along with other information. If this is correct, I think the problem might be that you are not passing the full path to the file. If the file is in the same directory as the script which sends the e-mail, I would use the example I posted above and change the file name to the variable you are passing in like this.

<cfmail
to=&quot;yourAddress@yahoo.com&quot;
from=&quot;yourAddress@yahoo.com&quot;
subject=&quot;File&quot;
mimeattach=&quot;#getdirectoryfrompath(cgi.path_translated)#\#fileName#&quot;
>
Message Here
</cfmail>

If your text box is called &quot;fileName&quot; and you type in the name of the file WITHOUT the path, then I believe this should do what you want.

Let me know if I'm still not understanding the problem.
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top