Consulting

Results 1 to 8 of 8

Thread: Solved: Remove all Bcc recipients

  1. #1

    Solved: Remove all Bcc recipients

    Greetings,

    Is there a way to remove all the BCC recipients ?
    like Recipients.removeall() ?

    Thanks in advance

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi and welcome to VBAX

    You're on the right track with the Recipients but what you'll need to do is check each repicient of the mail item to see it's type and if it's a BCC, delete it. Then save the mail item at the end[VBA]Dim objMail As MailItem
    Dim objRecip As Recipient

    For Each objRecip In objMail.Recipients
    If objRecip.Type = olBCC Then
    objRecip.Delete
    End If
    Next
    objMail.Save[/VBA]
    K :-)

  3. #3
    First of all I would like to thank you for welcoming me and for ur help.

    But for some weird reasonit is not working.It is not deleting all the Bccs.
    lets say i have 4 ppl in bcc it is only deleting 2 !
    [VBA]Dim SafeItem, oItem
    Dim objRecip As Recipient
    Set SafeItem = CreateObject("Redemption.SafeMailItem")
    For Each objRecip In Item.Recipients
    If objRecip.Type = olBCC Then
    objRecip.Delete
    End If
    Next
    Item.Save
    [/VBA]

  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    OK then, time for some debugging...
    Replace the line: objRecip.Delete
    with: Debug.Print objRecip.Name & " - " & objRecip.Type,
    run the code and open the Immediate window (Ctrl G)
    All the recipient names will be listed with their type (as an integer, olBCC = 3)
    Check your expected BCC names are listed with a 3 next to them - if not, there's your problem.
    If they are, then I'm not sure what to suggest...
    K :-)

  5. #5
    Sorry to inform you but the names are correct! but it is not deleting them all ! What are we going to do ?

    regards

  6. #6
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    How strange...
    Is the code you posted as you are using it? If so, I'm wondering which mailitem is being referred to !? Shouldn't this line:
    For Each objRecip In Item.Recipients

    be referring to the "Redemption.SafeMailItem" you create and read:
    For Each objRecip In SafeItem.Recipients
    K :-)

  7. #7
    No, i am deleting the recpients from Item.Recipients then saving Item and setting safeitem = item
    Thats not the problem.
    I even used ur code exactly as is and still the same problem:
    [VBA] Dim objRecip As Recipient
    For Each objRecip In Item.Recipients

    Debug.Print objRecip.Name & " - " & objRecip.Type

    Next
    For Each objRecip In Item.Recipients
    If objRecip.Type = olBCC Then
    objRecip.Delete
    End If
    Next
    For Each objRecip In Item.Recipients

    Debug.Print objRecip.Name & " - " & objRecip.Type

    Next
    Item.Save [/VBA]

    And the output was like this:
    1@1.com - 1
    '2@2.com' - 3
    '3@3.com' - 3
    '4@4.com' - 3
    '5@5.com' - 3
    '6@6.com' - 3

    1@1.com - 1
    '3@3.com' - 3
    '5@5.com' - 3

    Really weird !!!!

  8. #8
    I Managed to Solve it !

    I dont know what was the original problem, but here is the solution:
    [VBA]

    For i = 1 To Item.Recipients.Count

    If i <= Item.Recipients.Count Then
    If Item.Recipients(i).Type = olBCC Then
    Item.Recipients(i).Delete
    i = 0
    End If

    End If

    Next

    Item.Save

    [/VBA]

    Instead of using ur loop, I used this one.

    Thanks anyways for your time and help.

    Cheers


    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •