I'm using the following code for send email using email Template.
public void SendEmailUsingTemplate(IOrganizationService crmService,ActivityParty[] fromParty, ctivityParty[] toParty,string templateName,Guid regardingId, string regardingType)
{
try
{
// Create e-mail message.
var email = new Email
{
To = toParty,
From = fromParty,
DirectionCode = true
};
if (!string.IsNullOrEmpty(templateName))
{
Guid templateId = Guid.Empty;
// Get Template Id by Name
Entity template = GetTemplateByName(crmService, templateName); // Here I got the template Details
if (template != null && template.Id != null)
{
var emailUsingTemplateReq = new SendEmailFromTemplateRequest
{
Target = email.ToEntity<Entity>(),
TemplateId = template.Id,
RegardingId = regardingId,
RegardingType = regardingType
};
var emailUsingTemplateResp = (SendEmailFromTemplateResponse)crmService.Execute(emailUsingTemplateReq);
}
else
{
// “****No email template exists with the given name ****”);
}
}
}
catch (Exception ex)
{
throw;
}
}
But I need just create a email with retrieved email template in c# ? How can I achieve this ?