1

Hi is it possible to use custom object as the recipientType in visualforce email template rather than the standard objects like User, Contact and Lead?

0

No, the recipientType cannot be a custom object. A recipient must be a "person", which is a User, Lead, Contact, or Person Account. You can specify a "relatedTo" that may be any any standard or custom object that allows activities.

2
  • Thanks, I have the Attendee custom object (which is a "person") that I want to use as the recipientType. I want to send an email every time a attendee signs up an event, so in the email body it will need to have related list from the attendee as well. Thanks. – Johnny Situ Aug 3 '17 at 18:57
  • @JohnnySitu You can't define a custom "person" type. Call it a limitation of the platform. You'll need to use a design that leverages either leads or contacts. You can still use the attendee object to link a contact or lead to an event, but you'll need to rethink your current design. – sfdcfox Aug 3 '17 at 19:52
-1

Yes, If you are using custom controller and custom method to send email then you can use the custom object as the recipientType.

I have used custom object as a recipientType and it's working for me but yes i just want to be clear that i have used custom object using custom apex class and custom method,

Please see below piece of code that i used on my custom command button,

public PageReference SendPdfEmail()
{       

    try{

        EmailTemplate template = [Select Id from EmailTemplate where Name='Test PDF'];
        String emailURL = '/_ui/core/email/author/EmailAuthor?p3_lkid=' + CustomObjId + '&template_id=' + template.Id + '&retURL=%2F' + CustomObjId + '&p2_lkid=' +CustomObj.Contact_Name__c;

        PageReference quotePage = new PageReference(emailURL);
        quotePage.setRedirect(true);
        return quotePage;       

    }Catch(Exception e){
        return null;
    }

}

Hope it helps you out !!

1
  • "p3" is the "related to" field, not the "recipient" field. – sfdcfox Aug 3 '17 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.