Sunday, October 7, 2007

Attaching In-Memory PDFs to E-Mail

This is semi-old news but it's one of those things I didn't look into until I needed to do it. I'm working on a project right now and decided it would be extremely handy for me to generate a document with cfdocument, and in addition to writing the binary PDF data to the database (long story as to why writing it to disk isn't feasible in this case), I need to send the PDF as an attachment to an email.


A quick Google pointed me to an entry on Dan Switzer's blog (you may be familiar with Dan's qForms JavaScript form validation library), which in turn led me to an entry on Charlie Arehart's blog, and in the comments is a nice chunk of code by Jon Wolski that seems like it will do the trick. I haven't tested it thoroughly yet but on initial attempts it seems to work just dandy.


Anyway, just thought I'd point it out and also record it here for my own recollection, because I know six months from now I'll forget which project I did this on let alone how to accomplish it. ;-)


Comments



Yeah, just make sure your buffer size setting in the DSN is set large enough. Had some large PDF's that were getting chopped and corrupt. This was the last thing we thought of.



No comments: