Link to home
Start Free TrialLog in
Avatar of Ianaldo
Ianaldo

asked on

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.
Avatar of JeffHowden
JeffHowden

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.
Avatar of Ianaldo

ASKER

How do you get the files to atach to a zip??

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

Thanks,

Ian.
I've used the following with reasonable success.

http://www.cflib.org/udf.cfm?ID=744
Avatar of Ianaldo

ASKER

Could you send me some code demonstraing how to use the cfparam tage to add multiple attachments though??


Thanks!
ASKER CERTIFIED SOLUTION
Avatar of JeffHowden
JeffHowden

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ianaldo

ASKER

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.
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.
Avatar of Ianaldo

ASKER

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!!
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.
Avatar of Ianaldo

ASKER

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!
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>
Avatar of Ianaldo

ASKER

Ah rite, ill try that out later,jeff thanks again for all your help!! Much appreciated!!

Ian