Emailing Dynamically Created PDFs

Emailing Dynamically Created PDFs

Support · Oct 25, 2005
Having the ability to create great looking, DynamicPDF documents is one thing but we sometimes need those documents to get to an end user, a customer or a colleague in real time. Well, here is some helpful information that will allow you to email those PDFs from within your DynamicPDF applications. There are three basic steps for getting your PDFs emailed on the fly: 1. Create your PDF using DynamicPDF Generator for COM/ActiveX. 2. Using the "DrawToFile" method save that PDF to File. 3. Using the emailing functionality of the CDOSYS Library attach and send the PDF. First, create a PDF. If you are just getting started you can take a look at any of our Generator for COM/ActiveX examples for creating DynamicPDFs, http://www.DynamicPDF.com/Products/Generator/Examples.csp Second, you will need to use the "DrawToFile" method and save the PDF to an actual location on disk. Saving the file to an actual location on disk is required using CDOSYS. (There are third party tools out there that will allow you to attach a file from a memory stream if required.) Finally, use the "CDO.Message" object to create, attached and send the email. Create the "CDO.Message" object and then set its properties (to, from, body, etc.). Then add an attachment to the message and send it. Here is some sample code for ASP: Dim objDoc Set objDoc = Server.CreateObject("DPDF_Gen.Document") 'Create DynamicPDF Document Here objDoc.DrawToFile "C:\temp\document.pdf" Dim ObjSendMail Set ObjSendMail = CreateObject("CDO.Message") ObjSendMail.To = "receiver@domain.com" ObjSendMail.Subject = "Attached PDF Email" ObjSendMail.From = "sender@domain.com" ObjSendMail.TextBody = "This is the body of the email. The DynamicPDF is attached" ObjSendMail.AddAttachment "C:\temp\document.pdf" ObjSendMail.Send