在Outlook中如何实现自动密送


Software 2010-10-01 16:20:12 阅读167 评论1  字号: 订阅

密抄到多人这个需要用到宏的,1、在Outlook里面键入ALT+F11打开VBA编辑器;

2、键入CTRL+R激活左边的那个工程面板,展开并双击上面的“Project (VbaProject.OTM)/Microsoft Office Outlook 对象/ThisOutlookSession”;

3、将下面的代码粘贴到右边打开的编辑区里面去:
Option Explicit

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim oItem As MailItem
    Dim oRecipient As Recipient
    Set oItem = Item
    
    ' 在这里参考如下代码根据需要增删BCC收件人
    Set oRecipient = oItem.Recipients.Add("
[email protected]")
    oRecipient.Type = Outlook.olBCC
    Set oRecipient = oItem.Recipients.Add("
[email protected]")
    oRecipient.Type = Outlook.olBCC
    Set oRecipient = oItem.Recipients.Add("
[email protected]")
    oRecipient.Type = Outlook.olBCC
    
    oItem.Recipients.ResolveAll
    oItem.Save
    Set oRecipient = Nothing
    Set oItem = Nothing
End Sub

4、根据需要按照我上面代码中的注释增删BCC收件人地址;

5、键入CTRL+S保存,再键入ALT+Q退出VBA编辑器返回Outlook主界面;

6、选择菜单“工具-信任中心”,在弹出窗口中选择“宏安全性”;

7、选择“为所有宏提供警告”或者“不执行宏安全性检查”(建议选择前者);

8、重新启动Outlook,看到提示是否否用宏,选择启用。

现在你发出去的每一封邮件都自动抄送给了代码中设置的那些BCC收件人了。

----------

外附一则:

在outlook里面设置里面降低宏安全性;
重启outlook;
Alt+F11后,选择左侧的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 = "[email protected]" '请改成你要密送的邮件地址

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

保存即可。重启outlook即可。测试outlook2003~2010都没问题。
重点是要降低宏安全性,并适当重启。代码部分只需要修改红字部分即可

转自:  http://will0690.blog.163.com/blog/static/45668020109142012742/

你可能感兴趣的:(server,object,user,application,VBA,2010)