Activity Forums Salesforce® Discussions What for setTargetObjectId is used while sending an email in salesforce?

  • Prachi

    Member
    November 12, 2019 at 1:45 pm

    Hi,

    setTargetObjectId(targetObjectId) is used while sending email from Apex code using SingleEmailMessage.

    Required if using a template, optional otherwise. The ID of the contact, lead, or user to which the email will be sent. The ID you specify sets the context and ensures that merge fields in the template contain the correct data.

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos