Cannot change body of meeting request in Send and ItemSend events

Symptoms

You use the WordEditor property in the Outlook Object Model to change the body of a meeting request in the Send or ItemSend events, but the body does not change.


Resolution

There are three approaches to changing an appointment's body using the Outlook object model, and the behavior varies depending on approach and the version of Outlook being used.

For Outlook 2010 and later versions, you can modify the body using the Body, RTFBody or WordEditor properties as detailed below.

For Outlook 2007, you can modify the body using the Body or WordEditor properties as detailed below.


The Body property

The Body property can be used in Outlook 2007 and later versions to set body text without formatting. Changes made using this property in the Send or ItemSend event are saved in the meeting request.


The RTFBody property

The RTFBody property can be used in Outlook 2010 and later versions, and it returns and sets an RTF stream as the message body. Setting this property in the Send or ItemSend events can be used as a workaround. The following Visual Basic .Net code sample illustrates how to change the body in the ItemSend event. The code sample searches for the string "ABCDE" in the body and adds "123" at the beginning of that string.

Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
If Item.Class = 53 Then '53=olMeetingRequest
Dim MeetItem As Outlook.MeetingItem
objMeetItem = Item
Dim strOrigRTF As String
Dim strNewRTF As String
Dim pos As Integer
Dim dBytes As Byte() = objMeetItem.RTFBody
Dim enc As New System.Text.ASCIIEncoding()
strOrigRTF = enc.GetString(dBytes)
pos = InStr(strOrigRTF, "ABCDE")
If pos = 0 Then
MessageBox.Show("ABCDE not found.")
Else
strNewRTF = Left(strOrigRTF, pos - 1) & "123" & Mid(strOrigRTF, pos)
objMeetItem.RTFBody = System.Text.Encoding.ASCII.GetBytes(strNewRTF)
End If
End If
End Sub
Note In order to set the RTFBody property, you need to use a variable declared as a MeetingItem and not the variant Item object that is passed into the Send and ItemSend events.


The WordEditor property

The WordEditor property is available in Outlook 2007 and later versions, and it returns a Microsoft Word Document object. Changes made using this property in the Send or ItemSend event are not saved.

Properties

Article ID: 2605734 - Last Review: Feb 26, 2016 - Revision: 1

Feedback