When creating an Outlook email through VBA in Excel, this now results in error 287; more specifically on getting a string value from .HTMLbody. This problem now appears when we moved to the 365 version. Any thoughts?
The goal is to create an email, using the contents of an Excel sheet. The email should contain the Outlook signature (text and pictures) of the user that is working with the Excel sheet at that time (that can vary). So first the signature is supposed to be captured (from HTMLbody) and next additional content is to be added, derived from the Excel sheet.
This worked before but now, with O365 it results in error 287.
This is the relevant code:
Sub mailing(van, aan, CC, BCC, subj, body, att)
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
'NOW not working therefore commented
'With OMail
'.Display
'End With
'signature = OMail.HTMLBody <-- This causes problems
'end of commented
With OMail
.SentOnBehalfOfName = van
.To = aan
.CC = CC
.BCC = BCC
.Subject = subj
.HTMLBody = body
If att = "" Then
Else
.Attachments.Add att
End If
.Display
'NOW not working therefore commented
'.HTMLBody = body & signature
'end of commented
End With
Set OMail = Nothing
Set OApp = Nothing
End Sub