c# - Saving object of Mailitem or any property which can be used to invoke Mailitem which was saved -
i using vs 2010 , dot net framework 2.0 . have created project in extensibility->shared add-ins outlook.
i want save outlook.mailitem object in datatable on explorer_selectionchange() , use outlook.mailitem object manipulate subject , body after-wards.
when saving object of mailitem in datatable getting saved sys.comaddins. here code class variables :
private outlook.mailitem connectingmailitem; private outlook.inspectors inspectors; private outlook.application applicationobject; private object addininstance; private outlook.explorer explorer; datatable dtmailitem = new datatable();
onconnection :
explorer = this.application.activeexplorer(); explorer.selectionchange += new outlook.explorerevents_10_selectionchangeeventhandler(explorer_selectionchange); dtmailitem.columns.add("mailitem",typeof(outlook.mailitem)); tfollowup = new timer(); tfollowup.interval = 100000; tfollowup.tick += new eventhandler(tfollowup_tick);
explorer_selectionchange
void explorer_selectionchange() { if (connectingmailitem != null && connectingmailitem outlook.mailitem) { marshal.releasecomobject(connectingmailitem); // perform garbage collection gc.collect(); connectingmailitem = null; return; } foreach (object selecteditem in explorer.selection) { connectingmailitem = selecteditem outlook.mailitem; break; } if (connectingmailitem != null && connectingmailitem outlook.mailitem) { dtmailitem.rows.add(connectingmailitem); dtmailitem.acceptchanges(); } }
tfollowup_tick
void tfollowup_tick(object sender, eventargs e) { if(dtmailitem.rows.count <= 0) { foreach(datarow dr in dtmailitem.rows) { // manipulation code subject , body or remove mailitem datatable } } }
how can save object of mailitem or property identify mailitem saved
you try what's suggested in this question store entryidand retrieve later using same id.
Comments
Post a Comment