每当我回复/转发正文中带有特定“STRING”的电子邮件并在密件抄送中设置电子邮件地址时,如何制作一个脚本?
谢谢!
将代码放在 ThisOutlookSession 模块中,
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim olBcc As String
On Error Resume Next
'// set email address here
olBcc = "Address@domain.com"
Set olRecip = Item.Recipients.Add(olBcc)
olRecip.Type = olBcc
If Not olRecip.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 olRecip = Nothing
End Sub
对于特定消息,您需要使用 IF 语句来过滤消息。或类别字段,如果您需要使用一系列 If 语句,按类别过滤可能是最简单的。
If Item.Categories = "blabla" Then
olBcc = "address@domain.com"
ElseIf Item.Categories = "Important" Then
olBcc = "new@address.com"
Else
Exit Sub
End If
Set olRecip = Item.Recipients.Add(olBcc)