I update the dates within the subject line and body.
I am trying to add my default signature to the end of the email.
Sub AutomatedMessage()
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
signature = OMail.body
start_date = Format(Now, "dddd d mmmm")
end_date = Format(Now + 6, "dddd d mmmm")
start_date_short = Format(Now, "d mmmm")
end_date_short = Format(Now + 6, "d mmmm yyyy")
With OMail
.To = email@company.com
.CC = email@company.com
.Subject = "Email subject" & start_date_short & " to " & end_date_short
.Body = "Dear people, etc etc starting" & start_date & " and ending" & end_date & signature
End With
Set OMail = Nothing
Set OApp = Nothing
End Sub
This results in a runtime error 287.
When debugging, the .body
after .Display
has only contains <>, even though I can see the signature is in the email when it has opened.