Some time ago I posted an article describing the manner in which one can send custom email messages via a logic hook. Since then, several folks have asked if it is possible to leverage the email template system built into SugarCRM for generating the actual message.
It is certainly possible and that is exactly what we will cover in this post.
To save ourselves some time, we will simply modify the script from the previous post and change the relevant portions so as to cause it to use an e-mail template instead of the file based template it previously used. But before that, we need to create the e-mail template.
Create your e-mail template as you would any other, following these steps:
1. Select Emails > Create Email Template within SugarCRM
2. Compose your message and click Save when done
Next, we need the ID of the email template you just created. This will allow us to leverage it within the script, giving us our desired result.
To retrieve the ID:
1. Select Emails > View Email Templates
2. Click on the email template you just created
3. Copy the content from the address field in your web browser to your clipboard
4. Paste the content to Notepad or other format where it can be easily inspected
Once pasted, you should find that the address field contains something similar to the following:
The portion to the right of the equal sign is what we will need.
With the preliminary work out of the way, we can proceed to modify the script that sends the message. If you want to see the original script, take a look at the original post.