search outlook email recipients and remove specific addresses
I'm trying to search all recipients in an email before its sent and remove any email address that match "whatever@whatever.com", even if that email address resides in a distribution list. I came up with the following code so far... but I don't know how to remove an email address from a distribution list in the recipients, and ONLY from the recipients. So if it's part of a distribution list, I don't want to permanently remove it from the distribution list, just from the specific email being sent.
I was thinking maybe if I can explode the emails contained in the distribution list into normal email recipients, then remove the one I don't want, then it would work, but I don't know how to explode a distribution list.
Public Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)remAddress = "whatever@whatever.com"For Each emailAddr In Item.Recipients Select Case emailAddr.DisplayType Case olPrivateDistList, olDistList For Each dlMember In emailAddr.AddressEntry.Members If dlMember.Address = remAddress Then dlMember.Delete (????) Next dlMember Case Else If emailAddr.Address = remAddress Then emailAddr.Delete (????) End SelectNext emailAddrEnd Sub