如果我回复/转发电子邮件中的特定“STRING”并在BCC中设置电子邮件地址,我该如何制作一个运行的脚本?
谢谢!
答案 0 :(得分:1)
将代码放在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)