Multi-Attachment in cfmail??

Does anyone know how to attach more than one file with cfmail's mimeattach tag or any other method, for example i need to attch file1.doc, file2.swf and file3.pdf to the email, how do i do this??


Thanks for your help,

Ian.
LVL 2
IanaldoAsked:
Who is Participating?
 
JeffHowdenCommented:
<cfmail ...>
  <cfmailparam file="path to file">
  <cfmailparam file="path to file">
  <cfmailparam file="path to file">
  <cfmailparam file="path to file">
  Body of message
</cfmail>

It shouldn't be any more difficult than that.
0
 
JeffHowdenCommented:
Use the <cfmailparam> tag to attach as many files as you like.  Alternatively, you could do some file-zipping on the fly and attach the zip file to the email.
0
 
IanaldoAuthor Commented:
How do you get the files to atach to a zip??

Could you give me an example of some code you have?

Thanks,

Ian.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
JeffHowdenCommented:
I've used the following with reasonable success.

http://www.cflib.org/udf.cfm?ID=744
0
 
IanaldoAuthor Commented:
Could you send me some code demonstraing how to use the cfparam tage to add multiple attachments though??


Thanks!
0
 
IanaldoAuthor Commented:
Hey jeff, ok you've got the points, just one question though, im trying to implement the zip thing, but i dont really understand it, could you show me what you did, as in post the code you used and how you called it.

Thanks for your help,

Ian.
0
 
JeffHowdenCommented:
Well, make sure that all the files you want to zip are isolated to a directory of their own.  Assuming everything is in C:/Inetpub/wwwroot/zip/ and you want the zip file placed in C:/Inetpub/wwwroot/, simply call the ZipFileNew() function like so:

<cfscript>
  ZipFileNew(
    'C:/Inetpub/wwwroot/attachment.zip'
  , 'C:/Inetpub/wwwroot/zip/'
  );
</cfscript>

Then, simply attach attachment.zip to your email.
0
 
IanaldoAuthor Commented:
Well you see im not actually zipping a folder im zipping 2 files generated on the fly and they are saved to the server, the the zip thing picks them up and zips them, where do i state in the file i just need to send two files zipped:

'C:/Inetpub/wwwroot/zip/file.pdf'
And
'C:/Inetpub/wwwroot/zip/file2.swf'

I need to send these 2 files

Thanks again for your help!!
0
 
JeffHowdenCommented:
By telling it to zip C:/Inetpub/wwwroot/zip/ it knows to put those two files in the zip file.  The catch is that you can only have those two files in that folder because it'll place everything in that folder in the zip file.
0
 
IanaldoAuthor Commented:
Yeah you see thats the thing, i have a website that creates lots of files, and people will always be creating these files on the fly so there could well be more than one person creating these files to that folder, so possibly ill need some way that it can dynamically create a folder and then puts the files in the folder, i can do that easily, its just the creating the folder bit dynamically, then i can zip that folder, any ideas???

Cheers!
0
 
JeffHowdenCommented:
Yeah, create a folder using CreateUUID() for the name:

<cfscript>
  foldername = CreateUUID();
</script>
<cfdirectory action="create" directory="C:/Inetpub/woorot/zip/#foldername#/">
<cfscript>
  ZipFileNew(
    'C:/Inetpub/wwwroot/attachment.zip'
  , 'C:/Inetpub/wwwroot/zip/' & foldername & '/'
  );
</cfscript>
0
 
IanaldoAuthor Commented:
Ah rite, ill try that out later,jeff thanks again for all your help!! Much appreciated!!

Ian
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.