Question

I'm trying to set the RTFBody property of a TaskItem (using the Office PIAs). Below is a snippet of what I'm trying to do and it's throwing an exception. Has anyone tried to set the RTFBody before and if so, how are you doing it?

Dim oApp As Outlook.Application = New Outlook.Application
Dim t As Outlook.TaskItem = DirectCast(oApp.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem)
t.Status = Outlook.OlTaskStatus.olTaskNotStarted
t.Importance = Outlook.OlImportance.olImportanceNormal
t.Subject = "test subject"
t.RTFBody = System.Text.Encoding.ASCII.GetBytes("{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\*\generator Riched20 15.0.4599}{\*\mmathPr\mwrapIndent1440 }\viewkind4\uc1 \pard\f0\fs22 Test Body: First Line\parSecond Line of Text\par}")

I can retrieve the RTFBody property when debugging, but cannot set it.

Was it helpful?

Solution

Rather than setting RTFBody, simply setting the Body property to the (ANSI encoded) RTF byte array has the desired effect, cf. also this answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top