First you need to create an email template. Go to Settings | Templates | Email Templates:

Then click the New button and select the desired entity. If the entity you want to connect the email template to is not shown in the list, just select Global. It is not possible to extend the list of supported entities.

Create the template.

Remember to make a note of the template id (Guid) shown in the top browser bar. You’re probably going to need that in your code.

You can of course add fields from your selected entity in the template subject and body fields, but it is beyond the scope of this simple demonstration to explain that in detail.

Notice that I have added a logo image as attachment to the template. You can add attachments, but strangely enough, when you create a new email using the template, the attachments will not be added by default. The code below shows you how to solve that. It will also show you how to add extra attachments on the fly when you send the email.

Sample code to send an email with attachments using a mail template, connected to an Incident entity:

using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Tooling.Connector;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using Xrm;

namespace CrmDevelopersHowTo
    public static class SendEmailSamples
        public static void SendEmailUsingTemplate()
            // Initiate CRM-connection
            var conn = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CONN"].ConnectionString);
            var service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
            var context = new OrganizationServiceContext(service);

            Guid templateId = new Guid("----- Template Id -----");
            EntityReference templateRef = new EntityReference("template", templateId);

            Guid regardingObjectGuid = new Guid("----- Incident Id -----"); //Example - could be a lot of other entity types
            EntityReference regardingObjectRef = new EntityReference("incident", regardingObjectGuid);

            InstantiateTemplateRequest request = new InstantiateTemplateRequest()
                TemplateId = templateId,
                ObjectId = regardingObjectGuid,
                ObjectType = "incident"

            InstantiateTemplateResponse response = (InstantiateTemplateResponse)conn.Execute(request);
            Email email = (Email)response.EntityCollection[0];

            if (email == null)
                throw new Exception("Couldn't retrieve the selected template");

            Guid senderGuid = new Guid("----- System User Id -----");
            EntityReference senderRef = new EntityReference("systemuser", senderGuid);

            ActivityParty fromParty = new ActivityParty()
                PartyId = senderRef

            Guid recipientGuid = new Guid("----- Contact Id -----");
            EntityReference recipientRef = new EntityReference("contact", recipientGuid);

            ActivityParty toParty = new ActivityParty()
                PartyId = recipientRef

            email.From = new ActivityParty[] { fromParty };
            email.To = new ActivityParty[] { toParty };
            email.RegardingObjectId = regardingObjectRef;
            email.DirectionCode = true; //Sets the direction to "Outgoing"

            //Create the email entity
            Guid emailId = service.Create(email);

            //List and add template attachments (if any)

            List<ActivityMimeAttachment> atts = (from a in context.CreateQuery<ActivityMimeAttachment>()
                                                 where a.ObjectId == templateRef
                                                 select a).ToList();

            foreach (ActivityMimeAttachment att in atts)
                ActivityMimeAttachment attInstance = new ActivityMimeAttachment()
                    ObjectId = new EntityReference("email", emailId),
                    ObjectTypeCode = "email",
                    FileName = att.FileName,
                    MimeType = att.MimeType,
                    Body = att.Body


            //Add a custom attachment from the server

            FileInfo file = new FileInfo(@"C:\Temp\Logo.png");

            if (file.Exists)
                byte[] bytes = File.ReadAllBytes(file.FullName);
                string fileContent = Convert.ToBase64String(bytes);

                ActivityMimeAttachment attNew = new ActivityMimeAttachment()
                    ObjectId = new EntityReference("email", emailId),
                    ObjectTypeCode = "email",
                    FileName = file.Name,
                    MimeType = "image/png",
                    Body = fileContent


            SendEmailRequest req = new SendEmailRequest()
                EmailId = emailId,
                TrackingToken = "",
                IssueSend = true

            //Send the email
            SendEmailResponse res = (SendEmailResponse)service.Execute(req);

Once the email has been sent, it should be visible as an email activity in the selected incident entity’s timeline.
Observe: The sample supplied requires early bound entity classes for ActivityParty, Email, ActivityMimeAttachment, SendEmailRequest and SendEmailResponse!