QuestionHub gathers questions from leading sites, helping you to quickly and effectively find answers.

We’ve Updated

QuestionHub 2.0 has been launched!
Click here to read about our changes!

About Us

QuestionHub is a one-stop shop for finding all things Q&A online. Use QuestionHub as a starting point when searching for answers online!

Home > C# > How do I handle outlooks VSTO objects as if they are mailitems

Question:

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


I have written some VSTO (2003) code that sucessfully applies some 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 mandatory subject line changes according. The code is written to to operate on other types operate on microsoft.office.interop.outlook.mailitem However, I need the same code to attachements of mail items
"Microsoft.Interop.Outlook.somethingsendable"

http://stackoverflow.com/questions/4185899/how-do-i-handle-outlooks-vs to-objects-as-if-they-are-mailitems



See Related Questions There are 1 answer to this question.

Answers:



That's not going to work out wrap the PIA interfaces you need to support, and encapsulate the switching code there behind a common wrapper for the 'common' operations you want to use. You would create a SendableItem using either a MailItem or an AppointmentItem but once created, they look the same from the outside of the SendableItem of the box - AppointmentItem are completely different interfaces, so polymorphism is not an that you create a SendableItem and MailItem option.



The best I can suggest is class of your own to
wrapper.


Related Questions

Excel VSTO deployment issues.? Excel VSTO deployment issues.? I have developed a VSTO publish wizard. And I can successfully publish 2008 solution for excel 2003 add-in and deploying it using VSTO it but wh...

Software - 846 days ago - 0 Answers

VSTO 2005 SE with Office 2003. I am using VSTO 2005 SE required references. I am getting error as in Word 2003. In project added all the for designing Custom Task Pane 'ThisAddIn() does not contain a d...

vsto 2005 - 1,809 days ago - 0 Answers

Any idea why the main handle for asp objects are not working in my website? Any idea why the main handle for asp objects are not working in my website? Other handles are working. such as load. This code works. Protected Sub Button1_Load(ByVal s...

Programming & Design - 1,274 days ago - 0 Answers

TRACKING COOKIES (5 Objects) MRU LISTS (6 Objects) 5 Objects Identified 5 New Critical HELP? TRACKING COOKIES (5 Objects) MRU LISTS (6 Objects) 5 Objects Identified 5 New find the above after my Critical HELP? Every day I scan with Ad Aware SE and I scan. I quarantine...

Internet - 2,221 days ago - 3 Answers

 
 
QuestionHub gathers questions from leading sites , helping you to quickly and effectively find answers.