c# - Outlook mail integration with .net Desktop application -
i have window application running on system in can send mail through anywhere want integrate application outlook.
1.sent mail should show in outlook sent mail folder. 2.in case mail sending fail should display in outbox folder of outlook
go through following code:
outlook.application oapp = new outlook.application(); if (this.listviewcontacts.selecteditems != null && this.listviewcontacts.selecteditems.count > 0) { outlook.contactitem orecip = (outlook.contactitem) (this.listviewcontacts.selecteditems[0].tag); outlook.mailitem email = (outlook.mailitem) (oapp.createitem(outlook.olitemtype.olmailitem)); email.recipients.add(orecip.email1address); email.subject = "just wanted say..."; email.body = "have great day!"; if (messagebox.show( "are sure want send day message " + orecip.email1displayname + "?", "send?", messageboxbuttons.okcancel) == dialogresult.ok) { try { ((outlook.mailitem)email).send(); messagebox.show("email sent successfully.", "sent"); } catch (exception ex) { messagebox.show("email failed: " + ex.message, "failed send"); } } orecip = null; email = null; }
referance link:
step step implementation , explaination given in link.
hope helpful.
Comments
Post a Comment