Export (0) Print
Expand All
Expand Minimize

MailItem.RTFBody Property (Outlook)

Returns or sets a Byte array that represents the body of the Microsoft Outlook item in Rich Text Format. Read/write.

Version Added: Outlook 2010

expression .RTFBody

expression A variable that represents a MailItem object.

You can use the StrConv function in Microsoft Visual Basic for Applications (VBA), or the System.Text.Encoding.AsciiEncoding.GetString() method in C# or Visual Basic to convert an array of bytes to a string.

The following code samples in Microsoft Visual Basic for Applications (VBA) and C# displays the Rich Text Format body of the appointment in the active inspector. A MailItem must be the active inspector for this code to work.

Sub GetRTFBodyForMail() 
 
 Dim oMail As Outlook.MailItem 
 
 Dim strRTF As String 
 
 If Application.ActiveInspector.CurrentItem.Class = olMail Then 
 
 Set oMail = Application.ActiveInspector.CurrentItem 
 
 strRTF = StrConv(oMail.RTFBody, vbUnicode) 
 
 Debug.Print strRTF 
 
 End If 
 
End Sub 
 

private void GetRTFBodyForMail() 
 
{ 
 
 if (Application.ActiveInspector().CurrentItem is Outlook.MailItem) 
 
 { 
 
 Outlook.MailItem mail = 
 
 Application.ActiveInspector().CurrentItem as Outlook.MailItem; 
 
 byte[] byteArray = mail.RTFBody as byte[]; 
 
 System.Text.Encoding encoding = new System.Text.ASCIIEncoding(); 
 
 string RTF = encoding.GetString(byteArray); 
 
 Debug.WriteLine(RTF); 
 
 } 
 
} 
 

Show:
© 2014 Microsoft