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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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.
JeffHowdenCommented:
I've used the following with reasonable success.

http://www.cflib.org/udf.cfm?ID=744
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

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


Thanks!
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
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.
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!!
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.
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!
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>
IanaldoAuthor Commented:
Ah rite, ill try that out later,jeff thanks again for all your help!! Much appreciated!!

Ian
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.