【发布时间】:2023-03-18 04:42:01
【问题描述】:
我正在尝试在发送的自动邮件末尾添加签名。我希望签名成为运行宏的用户的默认签名。我编写的代码运行时不会崩溃,但不会插入签名。我在下面提供代码。
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 String
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 = "<span style='color:black'><p>Dear Team,</p>"
msg = msg & "Thank you in advance</span>"
On Error Resume Next
With OutMail
.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
【问题讨论】: