c# - Attach Generated PDFTK/iTextSharp PDF to MemoryStream to Mail -


i have pdf being generated pdftk (pdftoolkit). trying add returnedpdf gets saved downloads folder mailmessage in c#.

the pdf downloads no problem; however, attaching isn't going well.

var pdfcontents = pdfhelper.generatepdf(pdfpath, formfieldmap);  var newpdffer = pdfhelper.returnpdf(pdfcontents, "100-" + genuuid.text + ".pdf"); 

returns pdf filled in fine (as downloaded file)... however, can't seem figure out how attach in memorystream. trying attach , email it.

i receive email - attachment nothing in it. see code below:

    var doc = new document();     memorystream memorystream = new memorystream();     pdfwriter writer = pdfwriter.getinstance(doc, memorystream);      doc.open();      //doc.add(new attachment(thispdfnew));     //doc.add(new paragraph("second paragraph"));      writer.closestream = false;      doc.close();     memorystream.position = 0;      string toemailaddress = email.text;     string youremailadd = youremail.text;      mailmessage mm = new mailmessage();     mm.to.add(new mailaddress(youremail.text));      mailaddress addressbcc = new mailaddress(email.text);     mm.bcc.add(addressbcc);      mm.subject = "new form completed "+preparedby.text;     mm.body = "to view message, please use html compatible email viewer!";      mm.attachments.add(new attachment(memorystream, "100-" + genuuid.text + ".pdf"));     smtpclient client = new smtpclient();     client.port = 587;     client.deliverymethod = smtpdeliverymethod.network;     client.usedefaultcredentials = false;     client.credentials = new system.net.networkcredential("postmaster@this.com", "343543");     client.host = "smtp.mailchimp.org";       client.send(mm); 

i've spent last day googling , trying figure out how generated pdf mailstream message can't seem figure out. using pdftk uses itextsharp parse pdf.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -