Format of text to message body

1

I'm doing a macro in Excel which is used to send a meeting with Outlook, everything works fine but in the body of the message I want the text to be formatted, for example to put the text of colors, with bold, etc. Which I have not yet achieved, I share my code so they can help me.

Sub EnvioConvocatoriaT()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim itmApoint As Outlook.AppointmentItem

Set ns = ol.GetNamespace("MAPI")
Set itmApoint = ol.CreateItem(olAppointmentItem)

With itmApoint
.Start = DateSerial(2017, 8, 11) + TimeSerial(14, 0, 0)
.End = DateSerial(2017, 8, 11) + TimeSerial(16, 0, 0)
.Subject = "Correo de prueba"
.Body = "Este es un correo de prueba"
.Importance = olImportanceNormal
.Recipients.Add ("[email protected]")
.MeetingStatus = olMeeting
.Location = "Local Lima - 01"
.ReminderSet = True
.ReminderMinutesBeforeStart = 5
.Save
'.Send
End With
End Sub
    
asked by Freddy 10.08.2017 в 21:37
source

1 answer

0

In the case of a olAppointmentItem the only way to write a Body with format is using the property RTFBody , for which you should write the message with code RTF (Rich text format)

For example:

RtfText = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\colortbl;\red0\green0\blue0;}{\fonttbl
{\f0\fswiss\fcharset1252 Times New Roman;}
}{\*\generator CuteEditor 5.0;}\viewkind4\uc1\pard\cf1\f0\fs24\qj\b0\i0\ulnone Hola \cf1\f0\fs24\qj\b1\i0\ulnone Mundo\cf1\f0\fs24\qj\b0\i0\ulnone !}"
itmApoint.RTFBody = Encoding.Default.GetBytes(RtfText);

As RTFBody expects an array of bytes, it is necessary to convert the code RTF into an array using: Encoding.Default.GetBytes() , The format RTF is not very comfortable to write, but eventually you can save from Word to a file RTF and see to adapt it to incorporate RTFBody

    
answered by 23.12.2017 в 02:52