从vbs将密件抄送收件人添加到Outlook 2010

时间:2013-11-16 14:47:04

标签: vbscript

我使用Outlook 2010,我尝试使用Visuas Basic脚本而不是VBA添加密件抄送收件人

我的代码如下。发送电子邮件给收件人,但不发送给密送。 你知道任何人的解决方案吗?请注意,从VBA正常工作。

Sub sendcomment_click()
Set oMsg = Application.CreateItem(olMailItem)

 With oMsg
   .Recipients.Add("email address")
   Set objRecip= Item.Recipients.Add("email address")
   objRecip.Type = olBCC
   objRecip.Resolve
  .Subject = "New Comment by" 
  .Body = "sdfsdfsdf"
  .Send
End With

end sub

1 个答案:

答案 0 :(得分:1)

假设您已经拥有BCC的电子邮件地址,您只需添加电子邮件地址而无需解决。

除非您想首先解决它,然后从中获取电子邮件地址,然后您需要更多代码。顺便说一句,你应该在这个子目录之外定义Const olBCC = 3

Sub sendcomment_click()
    Set oMsg = Application.CreateItem(olMailItem)

    With oMsg
        .Recipients.Add ("email address")
        'Set objRecip = Item.Recipients.Add("email address")
        'objRecip.Type = olBCC
        'objRecip.Resolve

        ' Join Email addresses by "; " into ".BCC" as string
        .BCC = "Person.A@somewhere.com; Person.B@somewhere.com"

        .Subject = "New Comment by"
        .Body = "sdfsdfsdf"
        .Display ' Comment this to have it not show up
        '.Send ' Uncomment this to have it sent automatically
    End With

    Set oMsg = Nothing
End Sub

代码执行截图: code_executed