Sending custom templated emails using the Kentico API

Lee Conlin
Distinction
Published in
1 min readApr 26, 2019

I often find myself needing to send custom emails from my code in Kentico projects. To make life easier I created this method as a generic email sender.

I wrote this code in Kentico 10 but, as of writing this article, it was still good up to Kentico 12.

This can be used in a Web Method to allow your front-end javascript to trigger specific email templates, or in your back-end code to do the same.

To use it, create a new email template in Kentico using the “General” email type. Then simply call the method, passing in the template codename, the recipient(s) email address(es) and a dictionary of data that you want to use in the template.

The keys from the dictionary will be what you use in the template. i.e. {%MyCustomData%} … and will be replaced by the associated value from the dictionary.

Hopefully, others will find this useful. Let me know in the comments.

--

--

Lee Conlin
Distinction

By day I'm a software developer with over 20 years of professional experience. By night I step into other worlds through role playing games and creative writing