Monday 23 March 2015

Send email using Email Template CRM 2011, 2013 and 2015

Here is the code for sending an email via template using C# code

SendEmailFromTemplateRequest emailUsingTemplateReq = new SendEmailFromTemplateRequest
{
      Target = entEmail,
      // Template ID
      TemplateId = entEmailTemplate.Id,
      // The regarding Id is required, and must be of the same type as the Email Template.
      RegardingId = erfRecord.Id,
      RegardingType = Constants.OPPORTUNITY
};

// SendEmailFromTemplateRequest creates one more email for sending. So deleting the email created initially.
service.Delete(Constants.EMAIL, entEmail.Id);

--
Happy CRM'ing
Gopinath

No comments:

Post a Comment