In Outlook 2016 I generate automated emails using a recurring calendar appointment.
Private WithEvents olRemind As Outlook.Reminders
Dim strSubject As String
Private Sub Application_Reminder(ByVal Item As Object)
Set olRemind = Outlook.Reminders
'IPM.TaskItem to watch for Task Reminders
If Item.MessageClass <> "IPM.Appointment" Then
Exit Sub
End If
If Item.Categories <> "Send Message" Then
Exit Sub
End If
strSubject = Item.Subject
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
objMsg.To = Item.Location
objMsg.BCC = ""
objMsg.Subject = strSubject
objMsg.Body = Item.Body
objMsg.Attachments.Add "C:\Users\ABC\Desktop\XYZ.pdf"
objMsg.Send
'objMsg.Display
Set objMsg = Nothing
End Sub
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
For Each objRem In olRemind
If objRem.Caption = strSubject Then
If objRem.IsVisible Then
objRem.Dismiss
Cancel = True
End If
Exit For
End If
Next objRem
End Sub
The appointment the macro is keying off of:

I have two issues:
- The formatting (highlighting, underlining, text color, etc.) of the calendar item body is not carrying over into the body of the email.
- When adding an attachment to my email is there a way to reference the attachment of the calendar item rather than referencing the text file path where that attachment is saved?
I tried HTMLbody but that does not fix issue #1.
The
Bodyproperty is a plain text string. You need to use theHTMLBodyproperty if you want to see any formatted text on the email. However, theAppointmentItemclass doesn't provide theHTMLBodyproperty, to read the HTML markup from calendar items you need to read thePR_HTMLproperty value. See Get HTML body from Appointment for more information.Calendar items use the
RTFBodyproperty which has RTF formatting, the Outlook object model doesn't expose theHTMLBodyproperty for calendar items.Nope. You need to save the file to the disk. The Attachments.Add method accepts a string which can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment.
A low-level API (Extended MAPI) allows dealing with attachments binary data on the fly without any disk operations, but not the Outlook object model. Typically to you need to set the PR_ATTACH_DATA_BIN property which holds the attachment when the value of the
PR_ATTACH_METHODproperty isATTACH_BY_VALUE, which is the usual attachment method and the only one required to be supported.