我尝试自动实现此工作流程:
baz@example.com
,请注意非ASCII字符):Sub addbcc()
Dim objRecip As Recipient
Set oMsg = Application.ActiveInspector.CurrentItem
With oMsg
If InStr(1, oMsg.Subject, "xyžřy") > 0 Then
Set objRecip = oMsg.Recipients.Add("baz@example.com")
objRecip.Type = olBCC
objRecip.Resolve
End If
End With
Set oMsg = Nothing
End Sub
)我已经知道最后一部分 - how to add a BCC to a message,我使用InStr进行匹配:
{{1}}
但是,用户仍然需要记住按下按钮才能运行此宏,这比手动输入BCC更方便。打开此电子邮件时是否可以自动运行宏
。答案 0 :(得分:2)
打开此电子邮件时是否可以自动运行宏?
使用 NewInspector Event ,当用户或代码打开新窗口时会发生事件。
实施例
Option Explicit
Private WithEvents Inspectors As Outlook.Inspectors
Private Sub Application_Startup()
Initialize_handler
End Sub
Public Sub Initialize_handler()
Set Inspectors = Application.Inspectors
End Sub
Private Sub Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
If Inspector.currentItem.Class = olMail Then
If Inspector.currentItem.Parent = "Drafts" Then ' Drafts Folder
Debug.Print Inspector.currentItem.Subject ' Immediate Window
' Call Your Code
' Inspector.currentItem.BCC = "baz@example.com"
End If
End If
End Sub
答案 1 :(得分:1)
您可以使用ItemAdd监控草稿文件夹。在此处查看收件箱的想法。 How do I trigger a macro to run after a new mail is received in Outlook?
您可以在ItemSend中添加密送。 Outlook 2010 - VBA - Set bcc in ItemSend