Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SendGridMessage.cs #457

Merged
merged 2 commits into from
May 16, 2017
Merged

Update SendGridMessage.cs #457

merged 2 commits into from
May 16, 2017

Conversation

JefStat
Copy link
Contributor

@JefStat JefStat commented May 16, 2017

Personalization Tos field can be null

Snippet of the code that was throwing a null pointer exception

var msg = new SendGridMessage();
var i = 0;
        to.ForEach(o =>
        {
             if (o.Substitutions!= null && o.Substitutions.Any())
                {
                    p = new Personalization
                    {
                        Tos = new List<EmailAddress>(), //added to fix null pointer exception in sendgrid lib
                        Substitutions = new Dictionary<string, string>(o.Substitutions)
                    };
                }
                var newTemplateId = o.Metadata.ContainsKey("templateId")
                    ? o.Metadata["templateId"]?.ToString()
                    : null;
                msg.TemplateId = newTemplateId ?? msg.TemplateId;
                msg.AddTo(new EmailAddress(o.To),i,p);

Personalization Tos field can be null
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label May 16, 2017
@SendGridDX
Copy link

SendGridDX commented May 16, 2017

CLA assistant check
All committers have signed the CLA.

@thinkingserious
Copy link
Contributor

Thanks @JefStat,

Do you mind adding the same checks for AddBcc, AddCc while the hood is up? :)

@thinkingserious
Copy link
Contributor

Hello @JefStat,

Thanks again for the PR!

We want to show our appreciation by sending you some swag. Could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@thinkingserious thinkingserious merged commit 8785065 into sendgrid:master May 16, 2017
@JefStat JefStat deleted the patch-1 branch May 16, 2017 19:52
thinkingserious added a commit that referenced this pull request May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants