Greetings,
Is there a way to remove all the BCC recipients ?
like Recipients.removeall() ?
Thanks in advance
Greetings,
Is there a way to remove all the BCC recipients ?
like Recipients.removeall() ?
Thanks in advance
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 :-)
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]
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 :-)
Sorry to inform you but the names are correct! but it is not deleting them all ! What are we going to do ?
regards
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 :-)
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 !!!!
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