Posted by a ceTe Software moderator
Actually outputting the PDF to the user’s browser at the same time as emailing it is pretty straight forward to do. First, you should use the Draw method (instead of the DrawToWeb method) to get the output PDF as a byte array. Once you have the byte array of the PDF then you are basically going to stream that array to the browser (this is all the DrawToWeb method does) and then you have a byte array that you can use to create an attachment for your email as well. Streaming the PDF to the browser may look something like this:
byte[] pdf = objDocument.Draw();
Response.ContentType = "application/pdf";
Response.AddHeader( "content-disposition", "attachment; filename=MyPDF.pdf" );
Response.BinaryWrite(pdf);
Then to email the PDF our FireMail component was made specifically to do just that. It is very simple to setup an email and attach the same byte array to the email. Again, below is just some simple sample code continuing from the above example:
PlainTextMessage ptMessage = new PlainTextMessage("me@me.com", "you@you.com", "Mail with Stream Attachment", "Files Attached");
ptMessage.Attachments.Add(pdf, "MyPDF.pdf");
ptMessage.Send();
If you want to read more about the FireMail product take a look at the help topic on it here:
http://www.DynamicPDF.com/Support/NET_Help_Library_06_03/FireMail.html
All the above code was assuming that you just wanted to dynamically create the PDF document and email it without saving any copies to disk. If however you did in fact want to save a local copy then the concept would be similar however you would use the Draw Method to save the file (passing in the string to the location you wish to save it), redirect to the newly saved PDF’s URL, then just use that same string to the file location to attach your PDF to an email.
Either way it is pretty straight forward.
Let us know if you have any more questions.
Thanks,
ceTe Software Support