want to hide bcc field in outlook 2010 email using

2019-08-05 10:29发布

问题:

I'm trying to hide the Bcc field in an email that's currently being drafted in Outlook 2010 using VBA. The reason to hide it is that I'm using code to add an email address to Bcc which shows the field, but then I want the real-estate on the screen back.

Here's what I have so far (in ThisOutlookSession):

    Sub add_bcc_to_cur_email()
        Dim cur_msg As MailItem
        Set cur_msg = ActiveInspector.CurrentItem
        cur_msg.BCC = "first.last@domain.com" 'this works correctly
        cur_msg.GetInspector.CommandBars.ExecuteMso "Bcc" 'this does nothing
    End Sub

The first tree I barked up was thinking there was a way to control the visibility of the Bcc field directly, so I searched for information on that, and I found this page -- The second post seemed to have a solution, but that was for 2003, and alas, did not work.

Then I thought I could try to launch the Bcc item in the Ribbon which is located here: Options > Show Fields > Bcc. So I googled how to launch an item in the Ribbon, and came up with this page which had some interesting code, but the thread seemed to be inconclusive.

So either way -- Does anyone have any ideas? :)

Happy New Year, and thank you so much in advance~

回答1:

This worked for me in 2010

cur_msg.GetInspector.Commandbars("Menu Bar").Controls("View").controls("Bcc Field").execute