Breaking changes in SendGridForEpi

I've updated the Krompaco.SendGridForEpi add-on with support for CMS 11 and made it dependent on the latest SendGrid package.

This version (1.0.0) is now available on Episerver's NuGet feed.

SendGrid's official package is now a lot cleaner which is nice since I chose to reuse their models and concepts. One example:

await sg.client.mail.send.post(requestBody: mail.Get());

Now there's a SendEmailAsync() instead of the complete dynamic mess above:

await client.SendEmailAsync(sendGridMessage)

Or as you can conclude from Calling async methods within Episerver events by Māris Krivtežs:

var response = AsyncHelper.RunSync(() => client.SendEmailAsync(sendGridMessage));

Above call might something you would use when you need to send an e-mail instantly and not through the addon's queue. For example when user is starting a forgotten password flow or similar where direct delivery is key.

If you are one the downloaders; the models in the official SendGrid package are now changed but they are serialized in the exact same manor so you don't need to worry about existing data with this upgrade.

Your code constructing Mail objects will break and these are the most common adjustments needed for getting code to build after upgrading.

  • Mail has changed name to SendGridMessage
  • Email has changed name to EmailAddress
  • Setup up an empty list before adding, typically: Personalizations = new List<Personalization>()
  • Change mail.AddPersonalization() to mail.Personalizations.Add()
  • Change List<Email> to List<EmailAddress>

Check the source code on Github or the initial blog post if you missed the introduction.

Published and tagged with these categories: Episerver, ASP.NET