I'm trying to send email from Apex using a VF Email Template. The `<messaging:emailTemplate>` tag in the template specifies `recipientType='contact' relatedToType='MyCustomObj__c'`. I'm using code taken from [the answer to this question][1], basically verbatim: 1. create a new Messaging.singleEmailMessage() 2. setTargetObjectId(a valid contactid) 3. setWhatId(Id of a MyCustomObj__c) 4. setTemplateId(id of my VF template) 5. setSaveAsActivity(true) 6. Messaging.sendEmail(emails, false) The only difference in my code is that I repeat steps 1-5 to create a list<Messaging.Email>, add each message to the list after step 5, and save them all at once in step 6. This fails every time with message: `Messaging.SendEmailError[getTargetObjectId=null]`. If I instead `setSaveAsActivity(false)`, it succeeds. I have 'Enable Email Tracking' checked in Activity Settings in my org. Is there another setting I need to enable email tracking of mail sent to contacts? Can I not SaveAsActivity when using a Visualforce email template? I can't find any explicit prohibition. Something else? [1]:http://salesforce.stackexchange.com/questions/4608/how-do-wire-in-my-own-custom-object-into-an-email/4609#4609