Cannot change body of meeting request in Send and ItemSend events
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 IfEnd Sub
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.
Article ID: 2605734 - Last Review: 02/26/2016 03:49:00 - Revision: 6.0