c# - Not setting the property of incoming mails in MS Outlook 2010 -


i setting property (for making them read , high importance) of mail coming ms outlook 2010 inbox using below code -

 microsoft.office.interop.outlook.application myapp = new microsoft.office.interop.outlook.application();  microsoft.office.interop.outlook.namespace mapinamespace = myapp.getnamespace("mapi");  microsoft.office.interop.outlook.mapifolder myinbox = mapinamespace.getdefaultfolder(microsoft.office.interop.outlook.oldefaultfolders.olfolderinbox);        int = myinbox.items.count;  ((microsoft.office.interop.outlook.mailitem)myinbox.items[i]).unread = false;  ((microsoft.office.interop.outlook.mailitem)myinbox.items[i]).importance = olimportance.olimportancehigh; 

this works fine when 1 mail comes @ time (i can see mail read , high importance) after code execution when 3 or 4 mails coming @ time set property of 1 mail not 3 or 4 mails.

please suggest.

remember save message after setting property. importantly, code uses multiple dot notation - each ".", brand new com object, end setting importance property on object different 1 used set unread property.

int = myinbox.items.count; mailitem msg = (microsoft.office.interop.outlook.mailitem)myinbox.items[i]; msg.unread = false; msg.importance = olimportance. msg.save(); 

another problem assume last item in items collection latest one. not true. cremor suggested, use items.itemadd event, still not forget save message.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -