function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Support 3743Support 3743 

Displaying account-related partners in email template

I have a list of accounts and I want to display all the partners for one particular account in an email sent to that account. I'm using a Visual Force email template but I don't know how to fetch all the account-related partners in the email template. Can someone please help? Thank you!
Dinesh GopalakrishnanDinesh Gopalakrishnan
Hello,

<messaging:emailTemplate subject="Test Mail" recipientType="Contact" relatedToType="Account">
    <messaging:htmlEmailBody>
        <table>
            <tr>
                <th>Partner Name</th>
                <th>Email</th>
                <th>Phone</th>
                <th>City</th>
            </tr>
            <apex:repeat value="{!relatedto.Partner__c}" var="temp">
                <tr>
                    <td>{!temp.Name}</td>
                    <td>{!temp.Email}</td>
                    <td>{!temp.Phone}</td>
                    <td>{!temp.City}</td>
                </tr>
            </apex:repeat>
        </table>
    </messaging:htmlEmailBody>
</messaging:emailTemplate> 

Try this one and Change the Fields as Per Your Requirement.Let me Know the Output Once you Implemented this.
Kindly Mark this as a Best Answer if it Helps You!

Thanks,
Dinesh Kumar Gopalakrishnan
 
mukesh guptamukesh gupta
Hi,

you need to use soql in apex code like:
 
for (AccountPartner ap:[SELECT  Id, AccountToId, AccountTo.Name, Role
      FROM  AccountPartner
      WHERE  AccountFromId = :account.Id
                        LIMIT  100]) {
                            
                         system.debug('aaa ---- '+ap);   
                        }

 passs your account id in soql and send list to visualforce page email template.

if you need any assistance please let me know

Kindly mark my solution as the best answer if it helps you.

Regards
Mukesh