Activity Forums Salesforce® Discussions What is the use of setTargetObjectIds while sending mails in Salesforce?

  • What is the use of setTargetObjectIds while sending mails in Salesforce?

    Posted by Shweta on June 10, 2020 at 3:35 pm

    What is the use of setTargetObjectIds while sending mails in Salesforce?

    Sumit replied 4 years, 6 months ago 3 Members · 2 Replies
  • 2 Replies
  • MOHIT

    Member
    June 10, 2020 at 6:24 pm

    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.

  • Sumit

    Member
    June 11, 2020 at 6:55 am

    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.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos