Add BCC to Email with VBA in Outlook 2013

I cannot determine the correct VBA code for Outlook 2013 to add a fixed email address to the BCC email field while it is open for editing. I have the following code that creates a letter and then installs BCC.

I want to add BCC to the emails I am responding to, so the message will already be in the form of "draft".

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 

* Update *

I implemented excellent advice from Dmitry

My code now reads:

 Sub BCC() Dim objRecip As Recipient Set oMsg = Application.ActiveInspector.CurrentItem With oMsg Set objRecip = item.Recipients.add(" XXX@example.com ") objRecip.Type = olBCC objRecip.Resolve End With Set oMsg = Nothing End sub 

However, when I try to run it, I get the error "Runtime Error" 424 "Required Object" and selects the line:

 Set objRecip = item.Recipients.Add(" xxx@example.com ") 
+9
vba outlook-vba outlook
source share
2 answers

Instead of Application.CreateItem(olMailItem) use Application.ActiveInspector.CurrentItem . If you set the BCC property, you will destroy all existing BCC recipients. Use Recipients.Add (your comment is above) for each email address.

+5
source share

You need to define Item:

 Sub Bcc() Dim objApp As Outlook.Application Set objApp = Application Dim objRecip As Recipient Dim Item As MailItem Set Item = objApp.ActiveInspector.CurrentItem With objMsg Set objRecip = Item.Recipients.Add(" XXX@example.com ") objRecip.Type = olBCC objRecip.Resolve End With End Sub 
+1
source share

All Articles