The CRM has email templates that can be used for mail merge and other personalized emails. Sometimes it is desirable to send out emails from custom callouts. It would be considered best practice to use an email template in the CRM instead of hard-coding the email in the call out. This makes it easier to change the wording of the email without having to deploy new callout code. The process of sending an email is to locate a named template, then use the InstantiateTemplateRequest message to build an email based on that template, then to send the new email using the email functionality. The process seems very straight forward, but here are a couple of issues that I had encountered in my first attempts. - The functionality is broken unless you apply rollup 1 as a minimum. I have applied rollup 2 to get this to work for me.
- Microsoft changed the API in Rollup 1. It is required that you update your server and then your web references in order to get it to work.
- The InstantiateTemplateRequest class has a Subject that is supposed to be the subject of the email. The code would throw exceptions until I stopped setting it. The email template already handles the subject of the email, so I am unsure why there is a subject field on this request in the first place. The error code is 0x80040216.
|