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 few 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.

Added Tuesday 9 January 2018 22:20 — Tags for this page: Episerver, ASP.NET

Comments

Add Your Comment