• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 65
  • Last Modified:

Strip BCC off existing sent email

For outlook - is there a way to run a macro on a sent folder to strip the BCC recipient from an existing email message in the sent folder?
0
Jason
Asked:
Jason
  • 7
  • 4
2 Solutions
 
Bill PrewCommented:
Give this a try, select the sent email you want to remove the BCC from and run this macro.

Sub ClearBcc()

    Dim Session As Object
    Dim objItem As Object
    Dim i As Long
               
    If TypeName(Application.ActiveWindow) = "Explorer" Then
        Set Session = CreateObject("Redemption.RDOSession")
        Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    
        With Application.ActiveExplorer.Selection
            For i = 1 To .Count
                Set objItem = Session.GetRDOObjectFromOutlookObject(.Item(i))
                objItem.BCC = ""
                objItem.Save
            Next i
        End With
    End If
    
    Set Session = Nothing

End Sub

Open in new window


»bp
1
 
AlanConsultantCommented:
Hi,

Just to note, I am guessing you will have to install 'Redemption' to use Bill's code above:

http://www.dimastr.com/redemption/home.htm


Alan.
0
 
Bill PrewCommented:
Thanks Alan, that's a good point, I had "borrowed" an older macro I had that was changing the "LoadPictures" flag on emails.

I actually expect this could be done without Redemption since BCC should be exposed in the base object model, let me test that...


»bp
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Bill PrewCommented:
Okay, here's a version that doesn't use Redemption, which we don't need in this question...

Sub ClearBcc()

    Dim objItem As Object

    If Application.ActiveExplorer.Selection.Count > 0 Then

        For Each objItem In Application.ActiveExplorer.Selection
            If objItem.Class = olMail Then
                objItem.BCC = ""
                objItem.Save
            End If
        Next

    End If

End Sub

Open in new window


»bp
2
 
JasonAuthor Commented:
Thanks Bill,

That works, much appreciated.

Next question would be, is it possible to clear a single specific email address, leaving the others if there is more than one email address in the BCC field?

Jason
0
 
Bill PrewCommented:
Yes, we should be able to do that.

A question though, what is your goal in removing the specific email address from the sent email?  Is it just so it doesn't show in Outlook if anyone happened to view it?  Or is there more going on here than that?  Is ti prevent passing it along to a resend, or reply all or something?

The reason I ask is that information is actually stored in a couple of places in the stored email.  And depending on what your goal is may determine where we need to remove it from.


»bp
0
 
JasonAuthor Commented:
Hi Bill,

Thank you for your follow up.

I need to package a large number of emails into a PST file that I can share with my staff for a project they are working on, but do not want them to see the confidential recipient who was BCC'ed, but still need to maintain one visible BCC'ed email address for a bot that catalogs the emails in our database based on a file number in the subject.

So removing a specific email address from the BCC from all locations would be ideal.

Respectfully,
Jason
0
 
Bill PrewCommented:
Okay, let me try what I think needs to happen and see if it behaves as expected.


»bp
0
 
Bill PrewCommented:
Okay, this seems to work well in a test for me here, try it there.  I didn't test in an Exchange/AD environment, but hopefully it works there as well.

Sub ClearBcc()

    ' Declare local variables
    Dim objItem As Object
    Dim objRecipient As Outlook.Recipient
    Dim blnSave As Boolean
    Dim i As Long
    
    ' Specify the email address to remove from the BCC list
    Const strBCC = "username@domain.com"

    ' Make sure at least one email is selected
    If Application.ActiveExplorer.Selection.Count > 0 Then

        ' Look at each selected email
        For Each objItem In Application.ActiveExplorer.Selection
            
            ' Make sure it's an email item
            If objItem.Class = olMail Then
                
                ' Assume no changes made to this email
                blnSave = False
                
                ' Look at each item in the recipients collection
                For i = objItem.Recipients.Count To 1 Step -1

                    Set objRecipient = objItem.Recipients(i)

                    ' It is is a BCC item, and matches the email address we want to remove, delete it
                    If objRecipient.Type = olBCC And LCase(objRecipient.Address) = LCase(strBCC) Then
                        objRecipient.Delete
                        blnSave = True
                    End If
                    
                Next
                
                ' If we made a change to the email save it
                If blnSave Then
                    objItem.Save
                End If
            
            End If
        
        Next

    End If

End Sub

Open in new window


»bp
0
 
JasonAuthor Commented:
Hi Bill,

That last macro seems to work perfectly!

Thank you very much!!

Jason
0
 
Bill PrewCommented:
Great, glad that was useful.


»bp
0
 
JasonAuthor Commented:
Much appreciated!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now