c# - How do I handle outlooks VSTO objects as if they are mailitems -


i have written vsto (2003) code sucessfully applies mandatory subject line changes according attachements of mail items. code written operate on microsoft.office.interop.outlook.mailitem however, need same code operate on other types such microsoft.office.interop.outlook.appointmentitem instance(infact needs work user can send have subject).

assuming outlook item types have subject property, attachments property , save method, how can approach writing code works relevant interop.outlook types.

i tried addressing via reflection getproperty returing null can't use getvalue on it

 ? mi.gettype().getproperty("subject") null  ?(mi microsoft.office.interop.outlook.mailitem).subject "test subject" 

there doesn't seem generic outlookitem class can cast to, this. what's correct approach ?

edit: clarif code starts this...

     void application_itemsend(object item, ref bool cancel)      {             if (item microsoft.office.interop.outlook.mailitem)              {                 microsoft.office.interop.outlook.mailitem currentitem =                      item microsoft.office.interop.outlook.mailitem; 

then stuff currentitem (including passing to various functions typed microosft.office.interop.outlook.mailitem properties. want them handle "microsoft.interop.outlook.somethingsendable"

that's not going work out of box - appointmentitem , mailitem different interfaces, polymorphism not option.

the best can suggest create sendableitem class of own wrap pia interfaces need support, , encapsulate switching code there behind common wrapper 'common' operations want use. create sendableitem using either mailitem or appointmentitem once created, same outside of sendableitem wrapper.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -