ktzouv
ktzouv

Reputation: 35

Add bcc recipient to Outlook 2010 from vbs

I use Outlook 2010 and i try from Visuas Basic script not VBA to add Bcc Recipient

My code is the following. Send email to Recipient but not to Bcc. Do you know anyone the solution. Note that from VBA is working properly.

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

Upvotes: 1

Views: 2924

Answers (1)

PatricK
PatricK

Reputation: 6433

Assuming you have the email addresses for BCC already, you could just add email address without resolving it.

Unless you want to resolve it first then get the email address off it, then you need more code. By the way, you should define Const olBCC = 3 outside this sub.

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 = "[email protected]; [email protected]"

        .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 screenshot: code_executed

Upvotes: 1

Related Questions