For the complete documentation index, see llms.txt. This page is also available as Markdown.

How To: Add Email Recipients from Related Lists

Pull related list email addresses into To, CC, or BCC recipients.

Use addToEmail when a template should populate recipients automatically from queried records.

Problem

You want to automatically add email addresses from a related list as document recipients.

Solution

Add Contacts as primary recipients:

<!--{{!
<lineitemsSOQL>
<class>none</class>
<soql>SELECT Email FROM Contact WHERE AccountId = '{{!Account.Id}}' AND Email != null</soql>
<column addToEmail="To">Email</column>
</lineitemsSOQL>
}}-->

Add Account Team members as CC:

<!--{{!
<lineitemsSOQL>
<class>none</class>
<soql>SELECT User.Email FROM AccountTeamMember WHERE AccountId = '{{!Account.Id}}'</soql>
<column addToEmail="CC">User.Email</column>
</lineitemsSOQL>
}}-->

Add Created By users as BCC:

Important Notes

  • You must also add addToEmail as an Apex parameter to your S-Docs button URL.

  • Only non-null email addresses are included.

  • <class>none</class> prevents the email list from rendering in the document.

  • This works with any object that has email fields.

Complete Example

Button URL parameter:

Template code:

Tips

  • Filter aggressively so only intended recipients are added.

  • Combine with other SOQL filters for tighter control.

  • Test with a small group first.

  • Do not forget the button parameter.

Last updated

Was this helpful?