i know, how attach created pdf file windows form data new outlook email message. following code create pdf. write in same else brackets:
else { createpdf(); //this example emailmessage(); } private void emailmessage() { try { outlook.mailitem mailitem = (outlook.mailitem) this.createitem(outlook.olitemtype.olmailitem); mailitem.subject = "this subject"; mailitem.to = "someone@example.com"; mailitem.body = "this message."; mailitem.importance = outlook.olimportance.olimportancelow; mailitem.display(false); } catch (exception ex) { throw new exception("cdocument: error occurred trying create outlook email" + environment.newline + ex.message); } } public void createpdf() { try { string imagefile = ""; system.drawing.rectangle bounds = this.bounds; using (bitmap bitmap = new bitmap(bounds.width, bounds.height)) { using (graphics g = graphics.fromimage(bitmap)) { g.copyfromscreen(new point(bounds.left, bounds.top), point.empty, bounds.size); //picturebox1.image(); } //==================add firstname if (textbox1.text != null && textbox1.text.trim() != "") { imagefile = "c:/users/marc/desktop/" + datetime.now.tostring("dddd dd mmmm hh-mm-ss tt") + textbox1.text; } else { imagefile = "c:/users/marc/desktop/" + datetime.now.tostring("dddd dd mmmm hh-mm-ss tt") + "rectangle"; } bitmap.save(imagefile + ".bmp", imageformat.bmp); formtoimage(imagefile); } } catch (exception e) { messagebox.show(e.message.tostring()); } }`
to add attachment mailitem
, can use attachments.add
this:
mailitem.attachments.add(filename);
where filename
path on file system of file want add.
in case imagefile + ".bmp"
.
Comments
Post a Comment