我想在 VBA Outlook 2016 中编写一个代码,在我发送的每封邮件中发送一个密件抄送,我有很多发件人邮件,一个 Outlook 帐户上有很多电子邮件。
所以每次我从 x@domaine.com 发送电子邮件时,都会自动从 x@domaine.com 发送一封密件抄送电子邮件,如果我从 y@domaine1.com 发送,也会向 y@domaine1.com 发送密件抄送
我尝试了这段代码,但它不起作用,并且在我的安全宏中全部启用
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
Dim myOlApp As Outlook.Application
Dim myOlMsg As Outlook.MailItem
On Error Resume Next
Set myOlApp = CreateObject("Outlook.Application")
Set myMsg = myOlApp.ActiveInspector.CurrentItem
strBcc = myMsg.SenderEmailAddress
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If
Set objRecip = Nothing
End Sub