The recipients of a mail are as follow.
I tried to use foreach to delete all of the existing recipients but it failed to delete all(but deleted some). Also the dummy Write-Host worked in similar way.
But if test it only with dummy Write-Host, its output times are exactly same as the number of recipients.
See below:
[DBG]: PS C:\Users\carrot\Desktop\Quotation\AutoSendTender>> foreach ($objRecipient in $objMailItem.Recipients){Write-Host $objRecipient.Name}
aaaa@yandex.com
cccc@yandex.com
bbbb@yandex.com
dddd@yandex.com
[DBG]: PS C:\Users\carrot\Desktop\Quotation\AutoSendTender>> foreach ($objRecipient in $objMailItem.Recipients){Write-Host $objRecipient.Name;$objRecipient.Delete()}
aaaa@yandex.com
bbbb@yandex.com
Why and how to fix? Thanks.