You need to sign in to do that
Don't have an account?

Email a record and its related list
I just created a custom app and it has everything the marketing group wanted. However, at the end of the approval process it needs to send an email with the contents of the record (which is no problem) AND a listing of the related items.
I'm not sure how to send that list since it could be one entry or many and it is not part of the main object. It has a lookup relationship to the main object though.
Is there a way to somehow query the related list using Apex or some other method so that I could return the items in an email?
Thanks
I think Visualforce Email Templates might help you here: http://wiki.apexdevnet.com/index.php/VisualForceEmailTemplates_sample
All Answers
I think Visualforce Email Templates might help you here: http://wiki.apexdevnet.com/index.php/VisualForceEmailTemplates_sample
What object are you running the approval process on?
You could use Apex and a trigger that fires only when some condition on this record is true (i.e. after the approval is completed) which runs a query for all the records in the related list, then iterates through those records to build an email body. Finally, you'd use the Apex outbound email class to create and send the email to some specified distribution list.
I am not as familiar with approval processes, but I've done similar work sending out email alerts from Apex triggers and could provide some sample code if you provide the objects you're working with.
-- Matt
Hi,
just came across this and thought i could reply if this is not solved yet. Yes, VF email templates would work for this. Set the relateTo to the mainobject(here in this case quote). A quote might have multiple items. Items have a lookup to quote.
<messaging:emailTemplate subject="...." recipientType="Contact" relatedToType="Quote">
<apex:repeat var="cx" value="{!relatedTo.QuoteItems__r}">
<tr>
<td>{!cx.partname__c}</td>
<td>{!cx.partprice__c}</td>
</tr>
</apex:repeat>
................
..........