title: setWhatId in salesforce using email template
body: <p>i have to send an email to a user in salesforce using email template.this template contain merge field type of custom object.</p>
  
  <pre><code> Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
  mail.setTargetObjectId(user.get(0).id);
  
  
  mail.setTargetObjectId(user.get(0).Id)
  mail.setTemplateId(specifier.get(0).Template_id__c);
  mail.saveAsActivity = false;
  mail.setWhatId(custom_object.Id);
  </code></pre>
  
  <p>i read in documentation 
  If you specify a contact for the targetObjectId field, you can specify a whatId as well. This helps to further ensure that merge fields in the template contain the correct data. The value must be one of the following types:
  Account
  Asset
  Campaign
  Case
  Contract
  Opportunity
  Order
  Product
  Solution
  Custom</p>
  
  <p>but if we are sending email to a user not to contact then how to assign a custom object for merge field type in custom objects as in the above code</p>