[SalesForce] Is it possible to send email to an arbitrary recipient using a VF Template

I suspect the answer here is "No", but I thought I'd ask anyway. Can I send an email, using a VFTemplate, to an arbitrary email address, as opposed to a Contact, User, or Lead?

I need to send a fairly complex email, which will require a VF email template. All merge fields in the template will come from the relatedTo object (case), nothing from recipient. These emails will be sent to an email-to-fax service, where the email-to-fax address is stored in a custom field on an account. When creating the email template in the UI, the options for Recipient Type are Contact, User, and Lead. And the documentation for SingleEmailMessage.setTargetObjectId() says "Required if using a template, optional otherwise".

So, do I have any option besides creating a "dummy" contact on the affected accounts to stor the email-to-fax email address?

Best Answer

No there's not - it has to be a record in the system, and it has to be a Contact/User/Lead and not a custom object. I recently found this out the hard way.

You can send emails to any address via Apex, but you can't reference VF templates directly that way. For HTML emails like this, I often use Apex and have a class which is specifically designed to create and handle the HTML for me.