I have written some VSTO (2003) code that sucessfully applies some mandatory subject line changes according to attachements of mail items. The code is written to operate on microsoft.office.interop.outlook.mailitem However, I need the same code to operate on other types such as microsoft.office.interop.outlook.appointmentitem for instance(infact it needs to work for anything the user can send that would have a subject).
Assuming the outlook item types have a subject property, an attachments property and a save method, how can I approach writing code that works for all relevant interop.outlook types.
I tried addressing this via reflection but GetProperty is returing null so I can't use GetValue on it
? mi.GetType().GetProperty("Subject") null ?(mi as Microsoft.Office.Interop.Outlook.MailItem).Subject "Test Subject"
there doesn't seem to be a generic outlookitem class I can cast to, to do this. What's the correct approach ?
EDIT: To clarif my code starts like this...
void Application_ItemSend(object Item, ref bool Cancel) { if (Item is Microsoft.Office.Interop.Outlook.MailItem) { Microsoft.Office.Interop.Outlook.MailItem currentItem = Item as Microsoft.Office.Interop.Outlook.MailItem;
then does stuff to currentItem (including passing to to various functions currently typed with Microosft.Office.Interop.Outlook.MailItem properties. I want them to handle "Microsoft.Interop.Outlook.somethingsendable"
mi
declared as? – Steve Townsend