我已将我的联系人分配到各种类别。因此,我想创建一个规则,以便如果我将电子邮件发送给该类别之一中的任何联系人,则该电子邮件将被密件抄送至电子邮件地址。
这是我当前拥有的代码,我不断收到错误{438} Set oContact = oRecip.GetContact
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim oContact As Outlook.ContactItem
Dim oRecip
Dim Recip As Recipient
Dim BccRecip As String
Dim strCategoryName As String
Set oRecipients = Item.Recipients
Set oRecipient = Recipients(1)
Set oContact = oRecipient.GetContact
strCategoryName = oContact.Categories
strCategoryName = oContact.Categories
If InStr(LCase(strCategoryName), "test") > 0 Then
BccRecip = "abc@def.com"
Else
Exit Sub
End If
Set Recip = Item.Recipients.Add(BccRecip)
Recip.Type = olBCC
If Recip.Resolve Then
Cancel = False
Else
Cancel = True
End If
End Sub
预先感谢您的帮助。
答案 0 :(得分:1)
oRecip是收件人的集合。
您必须使用类似
Set oRecipients = Item.Recipients
Set oRecipient = Recipients(1)