Here's an abridged version of a function that I have that creates an
AppointmentItem. It won't be too difficult to modify it to create a
MailItem. You will need to set the following properties to utilize HTML
though...
..BodyFormat = olFormatHTML
..HTMLBody = "<HTML><H2>The body of this message will appear in
HTML.</H2><BODY>Enter the message text here. </BODY></HTML>"
If you go into VB Help for Outlook, look under
MICROSOFT OUTLOOK OBJECT MODEL
OBJECTS
M
MailItem
You should find everything that you need there. Also, if you click on
the link to the CreateItem article, you'll find a direct example that
creates a new mailItem.
Function createOutlookAppointmentFromId(lngTransportID As Long, frm As
Variant)
Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim mailbox As MAPIFolder
Dim targetCalendar As MAPIFolder
Dim newAppt As Outlook.AppointmentItem
Dim i As Integer
Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set mailbox = nms.Folders(1)
Set targetCalendar = mailbox.Folders("Calendar")
Set newAppt = objOutlook.CreateItem(olAppointmentItem)
With newAppt
.Start = dteDate & " " & dteTimeScheduled
.End = dteDate & " " & DateAdd("h", 1, CDate(dteTimeScheduled))
.Subject = strPrimaryPassenger
.Location = strLocation
.Body = "INSERT BODY TEXT HERE" 'getBodyText()
.BusyStatus = olBusy
.Categories = "Reservations"
.MessageClass = "IPM.Appointment.Reservations"
.Save
End With
If Err.Number = 0 Then
createOutlookAppointmentFromId = -1
Else
createOutlookAppointmentFromId = Err.Number
End If
DoCmd.Hourglass (False)
Set newAppt = Nothing
Set targetCalendar = Nothing
Set mailbox = Nothing
Set nms = Nothing
Set objOutlook = Nothing
End Function