'VSTO Outlook Plugin updates Appointment.Body and thus Outlook shows text instead of html part of multipart message
I receive multipart invitations which include calendar and text and html part. When I open those invitation mails in outlook it shows the html part. Now my code updates the text part with:
myAppointment.Body = myAppointment.Body.Replace(OutlookAddIn4.Resources.Resources.LinkToMeeting + " " + meetingLink, "");
myAppointment.Save();
This text is normally NOT included in the text part. Therefore this call DOES NOT change anything.
Although Outlook now shows the text part instead of the HTML part.
My questions: 1.) How can avoid this? 2.) Is there a chance to determine in my Plugin whether Outlook shows the html part (RTFBody that is, right) or the text part?
Thanks Hannes
Solution 1:[1]
Firstly, before unconditionally resetting the body, check if there is something to replace and only then do anything.
Secondly, you can take a look at the RtfBody
property and set it instead. If HTML is used, RTF will have the "\fromhtml"
header. Latest versions of Outlook support HTML, but HTMLBody
property has not been added to the AppointmentItem
object. In theory, you can set the PR_HTML
property, but PropertyAccessor.SetProperty
won't let you set it. If using Redemption is an option (I am its author), you can either set the RDOAppointment.HTMLBody
property or set PR_HTML
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |