Archived Forum Post

Index of archived forum posts

Question:

Removing email recipients

Mar 08 '13 at 10:36

I'm working with email, in C++

I need the ability to remove To, CC or Bcc recipients at will, similar to removing an attachment using "DropSingleAttachment" to remove an attachment from the email object. Is there such a method that I'm missing? I am currently iterating the list to save it, and then adding then all back in except for the one I need to remove...

Thanks, Avis


Answer

Unfortunately, there is no simple method to do it.

A slight modification to what you might be doing is this: Iterate over the list to build a string of comma-separated email addresses, but omit the email address to be removed. Then call email.AddHeaderField("To", strCommaDelimitedEmailAddresses)

The AddHeaderField method will replace the header if it already exists. (The AddHeaderField2 method can be called to add a duplicate header that has the same name as one that already exist. In this case, you'd want the header field to be replaced.)