|
以下的代码是以前的一位论坛大大写的,在OUTLOOK中自动密送给指定的邮箱.
想请各位高手帮忙修改一下条件,在收件人或抄送人中如果有不包含"@126.com"的邮箱地址,才自动密送给指定的邮箱
在outlook中alt+F11打开vba,把下面的内容放到"ThisOutlookSession"中就可以实现每次写完邮件点“发送”的时候自动添加密送地址。
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
On Error Resume Next
strBcc = "XXXXXXXX@163.com" '这里填写你要密送的邮箱
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "不能解析密件抄送人邮件地址, " & _
"请确认是否仍然发送邮件?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"不能解析密件抄送人邮件地址")
If res = vbNo Then
Cancel = True
End If
End If
Set objRecip = Nothing
End Sub
|
|