View Full Version : Solved: Remove all Bcc recipients
bbb_dinky
09-19-2005, 12:32 AM
Greetings,
Is there a way to remove all the BCC recipients ?
like Recipients.removeall() ? :)
Thanks in advance
Killian
09-19-2005, 01:17 AM
Hi and welcome to VBAX :hi:
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 endDim 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
bbb_dinky
09-19-2005, 02:09 AM
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 :dunno !
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
Killian
09-19-2005, 06:47 AM
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... :think:
bbb_dinky
09-19-2005, 07:05 AM
Sorry to inform you but the names are correct! but it is not deleting them all ! What are we going to do ? : pray2:
regards
Killian
09-19-2005, 08:22 AM
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
bbb_dinky
09-19-2005, 11:38 PM
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:
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
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 !!!! :banghead:
bbb_dinky
09-20-2005, 01:23 AM
I Managed to Solve it ! :yes
I dont know what was the original problem, but here is the solution:
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
Instead of using ur loop, I used this one.
Thanks anyways for your time and help.
Cheers
:beerchug:
Regards
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.