Some emails we receive in our system have a comma in their display names. For example: "Lab, Kevin kevinlab@email.com".
I noticed we could set the proper display name if we create the MailAddress ourselves.
var test = new MailAddress("kevinlab@email.com", "Lab, Kevin");
However, this would require us to write the parsing logic of the inputs.
Attempting to add this to a new MailAddressCollection fails because the comma is interpreted as a delimiter, and just "Lab" is added.
var toAddresses = new MailAddressCollection();
toAddresses.Add("Lab, Kevin <kevinlab@email.com>");
The easy fix is to simply parse out the comma.
var toAddresses = new MailAddressCollection();
toAddresses.Add("Lab Kevin <kevinlab@email.com>");
but then the display name becomes "Lab Kevin". Is there any way to have it included in the display name (i.e. "Lab, Kevin")?