Code posted here and been reported to work, doesn't work for me.
This code throws
Run Time Error '287 Application-defined or object defined error
on the line Signature = Outmail.body
.
I want the default signature for the current Outlook user.
Private Sub Command33_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim currentDate As Date
Dim DeliveryDate As String
Dim Recipients As String
Dim CarbonCopy As String
Dim Signature As Variant
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
currentDate = Format(Date, "dd/mm/yyyy")
Recipients = "a@gmail.com"
CarbonCopy = "b@gmail.com"
Signature = OutMail.Body
'msg hasn't been defined so it's commented out. msg in the body has been replaced with "msg".
'msg = "<span style='color:black'><p>Dear Team,</p>"
'msg = msg & "Thank you in advance</span>"
On Error Resume Next
With OutMail
'Capture signature block.
.Display
Signature = .HTMLBody
.To = Recipients
.CC = CarbonCopy
.Subject = "PSR " & currentDate
.HTMLBody = "<span style = 'color:#1F497D'>" & "msg" & "</span>" & Signature
.Attachments.Add ThisWorkbook.FullName
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub