Sendgrid-csharp: BCC and CC Check before sending

Created on 21 Jun 2017  路  4Comments  路  Source: sendgrid/sendgrid-csharp

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
}
medium help wanted help wanted community enhancement up for grabs up-for-grabs

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:

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.

All 4 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivivanov picture ivivanov  路  3Comments

bogacg picture bogacg  路  3Comments

thinkingserious picture thinkingserious  路  4Comments

shiglet picture shiglet  路  3Comments

charles-smith picture charles-smith  路  5Comments