<messaging:emailTemplate subject="Invoice Request" recipientType="Contact" relatedToType="Account">
<messaging:htmlEmailBody >
<c:InvoiceRequestEmailComponent greet="{!greeting}"/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Where I can get the "greetings" variable from the controller and use it in the email. When I add the component to my VF page:
<c:InvoiceRequestEmailComponent greet="{!greeting}"/>
It shows me the email body WITH the string I just entered, which makes sense as it is within that page instance. But when I send an email I can't figure out how to access the variable within my particular instance.
I think I might need to initialize a PageReference and somehow refer to that in the component, or pass in the variable in my email method. It is clear that the email template cannot access the "greetings" variable when it doesn't know what instance it's looking at, but I'm not sure how. I have also looked into the component's relatedTo and email's whatId but it seems they address sObjects field parameters, or I just can't figure out how to use them with user-inputted strings.Thanks in advance, I can post all my code if required.1 answer
Hi Jacky, Please check with below links which might help you further.
- https://salesforce.stackexchange.com/questions/21639/how-to-pass-paramaters-from-an-email-template-into-a-custom-component
- https://salesforce.stackexchange.com/questions/35268/how-to-pass-values-from-visualforce-email-template-to-custom-component
- https://salesforce.stackexchange.com/questions/1242/passing-custom-string-into-a-salesforce-email-template
Hope this helps.
Thanks,Nagendra