Setting AppointmentItem.RTFBody using late binding creates a TargetInvocationException

Add-in Express™ Support Service
That's what is more important than anything else

Only registered users are allowed to subscribe.
Setting AppointmentItem.RTFBody using late binding creates a TargetInvocationException
 
Subscribe
Inspirometer Developer




Posts: 12
Joined: 2017-10-13
I am currently in the process of porting our Outlook add-in over from standard VSTO to ADX. One problem I came across when doing this is in setting the RTFBody of AppointmentItem objects. Our add-in needs to support all versions of Outlook from 2007 up. I understand that RTFBody was only added as an option in 2010, however I should still be able to access the property with reflection for versions later than 2010. There is, however, a bug. Dmitry Streblechenko pointed out on MSDN that you cannot set the RTFBody using IDispatch::Invoke ((https://social.msdn.microsoft.com/Forums/en-US/3c02ffe9-7375-4fed-804f-514820b6fe57/late-binding-mailitemrtfbody-with-invokemember-vsto-4-office-20072010-net35?forum=vsto).

I don't think it's likely Microsoft is going to fix this any time soon so how can I go about setting the RTFBody on an AppointmentItem without losing support for 2007?
Posted 13 Oct, 2017 08:20:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Inspirometer Developer,

Off the top of my head I can suggest the following workarounds for this RTFBody problem:
- You can try to use the WordEditor property and the Word Object Model (Word._Document) capabilities instead of RTF.
- You can put aside this RTF part of your project for now, and port the rest. When everything except RTF works, you can replace PIAs from version 2007 with those of 2010 and use early binding.
Posted 13 Oct, 2017 09:35:04 Top
Inspirometer Developer




Posts: 12
Joined: 2017-10-13
Using the WordEditor property worked fantastically. Thanks. For anyone that comes across this thread in the future you'll find this link handy. https://msdn.microsoft.com/en-us/library/6b9478cs.aspx
Posted 16 Oct, 2017 05:35:56 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Inspirometer Developer,

Thank you for the good news and useful link!
Posted 16 Oct, 2017 06:05:36 Top