我有当前的 vba 代码来自动生成到期电子邮件以符合 CPR 要求。我想在电子邮件底部添加我的默认签名。我需要如何编辑以下内容才能做到这一点?
Sub Send_Expired_CPR()
Dim olApp As Object
Dim olMailItm As Object
Dim iCounter As Integer
Dim Dest As Variant
Dim SDest As String
Dim OutApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
' Create a new Outlook object
For iCounter = 2 To WorksheetFunction.CountA(Columns(1))
Set OutApp = CreateObject("Outlook.Application")
Set objOutlookMsg = OutApp.CreateItem(olMailItem)
' Subject
strSubj = "Immediate Action Required: Expired CPR Certification for "
On Error GoTo dbg
' Create a new item (email) in Outlook
strBody = ""
useremail = Cells(iCounter, 4).Value
FirstName = Cells(iCounter, 5).Value
Expiration = Cells(iCounter, 9).Value
Login = Cells(iCounter, 3).Value
CertificationNumber = Cells(iCounter, 16).Value
CertificationVendor = Cells(iCounter, 15).Value
'Make the body of an email
strBody = "Dear " & FirstName & "," & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Your current CPR First Aid Certification from " & CertificationVendor & " (Certificaiton Number: " & CertificationNumber & ") is expired as of " & Expiration & "." & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Please work with your site leadership team to schedule a CPR First Aid Training class. Trainings must be scheduled two weeks in advance." & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Let me know if you have any questions. Thanks!"
strBody = strBody & vbCrLf
objOutlookMsg.To = useremail
objOutlookMsg.Importance = olImportanceHigh
objOutlookMsg.Subject = strSubj & Login
objOutlookMsg.BodyFormat = 1
' 1 – text format of an email, 2 - HTML format
objOutlookMsg.Body = strBody
objOutlookMsg.Display
Next iCounter
dbg:
'Display errors, if any
If Err.Description <> "" Then MsgBox Err.Description
Set objOutlookMsg = Nothing
Set OutApp = Nothing
End Sub
我尝试过谷歌搜索和搜索许多不同的先前提出的问题。
您可以使用 .Body 属性在 VBA 中添加默认签名。请参阅 Exclaimer 指南此处了解详细步骤。