Changed in rendering the templates for sending the emails.

In order to handle for rendering the templates for sending the mails is changed by using isinstance.