You need to sign in to do that
Don't have an account?
John Upton 8
How to use Visualforce email template with 'Related To' relationship.
I have created a table to house basic information for putting into an email (subject, intro etc). I will call this EMAIL. I have created a child table to house the content for emails, so each EMAIL object can have one or more CONTENT objects.
I have created a many-many relationship between CONTACT and EMAIL via another table called LINK.
I have two email templates. One is 'Custom' and as follows. This works fine, when I trigger it (by adding a LINK object), I get an email send to my Contact with both the expected merge fields filled in.
Dear {!CONTACT.FirstName}, Intro: {!EMAIL__c.Introduction__c}
However, I have a second template created using Visualforce (below). If I switch my email alert to use it instead, then perform the same action to get the email to be sent to a Contact, neither the Contact's Name or the EMAIL Introduction is merged in! Also note that, if I use this template and 'Send Test and Verify Merge Fields', entering my Contact and EMAIL ID causes the merge from both objects to work perfectly! Can anyone offer any advice?
Thanks
<messaging:emailTemplate recipientType="Contact"
relatedToType="Queued_Email__c"
subject="ed test 3">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>{!relatedTo.Introduction__c}</p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
I have created a many-many relationship between CONTACT and EMAIL via another table called LINK.
I have two email templates. One is 'Custom' and as follows. This works fine, when I trigger it (by adding a LINK object), I get an email send to my Contact with both the expected merge fields filled in.
Dear {!CONTACT.FirstName}, Intro: {!EMAIL__c.Introduction__c}
However, I have a second template created using Visualforce (below). If I switch my email alert to use it instead, then perform the same action to get the email to be sent to a Contact, neither the Contact's Name or the EMAIL Introduction is merged in! Also note that, if I use this template and 'Send Test and Verify Merge Fields', entering my Contact and EMAIL ID causes the merge from both objects to work perfectly! Can anyone offer any advice?
Thanks
<messaging:emailTemplate recipientType="Contact"
relatedToType="Queued_Email__c"
subject="ed test 3">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>{!relatedTo.Introduction__c}</p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
then the component (named emailTemplateComponent) looked like this...
Then the controller should have something like this....
It's not all exact code - but the concept is that the related and recipient IDs are passed to the component and to the controller. Then you can do stuff with them in the controller.
Like I said - someone else might have a better or more precise solution.
Hope you are working in Salesforce platform :) , since this is a 3 year old discussion
I have the same situation where RelatedTo.Id is passed to the controller and the code is in tact.
Like John mentioned, it is working in the 'Send Test' preview, but the actual email is not sending the info.
Any pointers much appreciated!
Thanks,
Chellappa
Could embed a link to the "relatedTo" object(Case) in the recipient object (Contact), but that is very kludgey and risks other performance and maintainability issues.