0

How can I set a ewsAppointment/ewsTask rtf body? Looks possible through an extended property, but I can't get this to work.

I was trying with getting the extended property like this -

ExtendedPropertyDefinition epd = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.PublicStrings,"PR_RTF_COMPRESSED",MapiPropertyType.Binary);

and setting it to a byte array of my rtf text - but that's not working.

Also - I'm trying to figure out if I should stick with html/rtf. Looking at EWS manged API - Appointment with Html Body and Outlook 2013 and links on that post, it sounds like it might be safer to always set RTF. Is this correct?

Thanks!

Community
  • 1
  • 1
Mike Turner
  • 471
  • 1
  • 7
  • 22

1 Answers1

1

Your property definition is incorrect it should be

ExtendedPropertyDefinition epd = new ExtendedPropertyDefinition(0x1009, MapiPropertyType.Binary);

as per https://msdn.microsoft.com/en-us/library/office/cc815911.aspx because this is a tagged property.

it sounds like it might be safer to always set RTF. Is this correct?

With Contacts and Appointment generally yes but you need to make sure you get the CompressedRTF format correct. You may also need to modify some of the other properties listed in https://msdn.microsoft.com/en-us/library/hh369831(v=exchg.80).aspx

Cheers Glen

Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • Thanks Glen. Your solution is not throwing the error I was getting. But I'm still not getting the body looking good in Outlook. How do I compress my RTF? And do you know what else needs to be set? – Mike Turner Apr 05 '16 at 19:50
  • The spec to do it is published on https://msdn.microsoft.com/en-us/library/cc425505(v=exchg.80).aspx I don't know of any libraries that implement this.Probably using a Mapi editor like MFCMapi or Outlookspy will help to look into the content further. – Glen Scales Apr 06 '16 at 03:46
  • It sounds like your not getting the RTF format correct (or setting it at all) as I mentioned before you need to use a Mapi editor to look at properties and their content. If you set the content how you want it using Outlook then view the property you should see how you need to format it correctly. – Glen Scales Apr 18 '16 at 02:32
  • Is this the way to do it for a task too? Or is there something that needs to be changed... It doesn't seem to be working for tasks – Mike Turner May 16 '16 at 03:05
  • Yes it is the same, I don't mean to harp on this but if you create a Task in Oultook set the body and have a look at it with a Mapi editor it will answer your question. If your not using that method to confirm it you will get inconsistent results (because of the way the Exchange store does its conversions) – Glen Scales May 16 '16 at 04:43
  • I don't understand bec I tried saving the text that I read off a different appointment PR_RTF_COMPRESSED property in Outlook spy as a text file. I tried setting the 0x1009 property of another appointment by File.ReadAllBytes(text file) and it's still not looking right in outlook desktop. Any ideas? – Mike Turner May 25 '16 at 01:52