I posted this issue a while back here
https://github.com/sendgrid/sendgrid-csharp/issues/297
It appears you only added the appropriate fix to the .clear() method. However i ran into an instance where a developer set the BCC and CC fields on a personaliztion object to
new List<EmailAddress>();
this caused there to be essentially a blank list. It would be better error handling to add a check on the process that builds the email request to check if there are BCC and if so add them to the JSON output as such
if (bccAddresses != null && bccAddresses.Count() > 0)
{
// ADD TO JSON OUTPUT
}
Hi @LorenDorez,
Thanks for submitting this request! I have added it to our backlog. It can gain priority via additional votes and/or a PR.
With Best Regards,
Elmer
I had a similar issue. We have a segment of code that overrides all the outgoing emails for testing.
The following works:
foreach (var personalization in message.Personalizations)
{
personalization.Tos =
new List<EmailAddress>(overrideEmailRecipient.Split(';').Select(s => new EmailAddress(s)));
personalization.Ccs = null;
personalization.Bccs = null;
}
If those nulls are new List<EmailAddress>() instead, the email does not send.
Hello @daerogami,
Thanks for taking the time to offer your solution, we really appreciate it! Could you please take a moment to fill out this form so we can send you some swag?
Also, PRs are greatly appreciated if you are up to it :)
With Best Regards,
Elmer
Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!
Most helpful comment
I had a similar issue. We have a segment of code that overrides all the outgoing emails for testing.
The following works:
If those
nulls arenew List<EmailAddress>()instead, the email does not send.