Outlook 2007 实现自动添加密送的方法

时间:2023-03-08 17:55:17
Outlook 2007 实现自动添加密送的方法

1)在Outlook里面键入Alt+F11打开VBA编辑器;
   
2)激活左边的工程面板,展开并双击上面的“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

Set oRecipient = oItem.Recipients.Add("user1@server1.com")

oRecipient.Type = Outlook.olBCC
    Set
oRecipient = oItem.Recipients.Add("user2@server2.com")

oRecipient.Type = Outlook.olBCC
    Set
oRecipient = oItem.Recipients.Add("user3@server3.com")

oRecipient.Type = Outlook.olBCC
   
   
oItem.Recipients.ResolveAll
   
oItem.Save
    Set
oRecipient = Nothing
    Set oItem =
Nothing
End Sub

4)根据需要在上面代码中的注释增删BCC收件人地址;保存,退出VBA编辑器,返回Outlook主界面;
   
5)选择菜单“工具-信任中心”,在弹出窗口中选择“宏安全性”,选择“为所有宏提供警告”或者“不执行宏安全性检查”(建议选择前者);

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

7)现在,新建邮件中虽然看不到密送收件人,但是发出去的每一封邮件都会自动抄送给了代码中设置的那些BCC收件人了。