You need to sign in to do that
Don't have an account?
Zach Gavin Delacroix
Using Custom Controller in Visualforce Email Template
Hello Experts,
I'd like an advise on how to use custom controller in Visualforce Email Template.
Basically, I would create a Controller like this.
Then would reference the code to the Component like this.
Then use the component in the Template like this.
This approach works great. But I'd like to have the Repeat tag in my visualforce Template Intead of using it in the Component. One reason is that when I do styling from the Component, the Style does not work when the Visualforce Email Template is Sent through email.
in the Preview of the VisualForce Page, it looks like this one below. (Note, I'm using style here from the Component that I have created for the custom controller)
But when it's sent to my email, it will look like just a plain text. Something like below.
Does anyway here encountered issues like this or have solution for this one?
Thanks a lot :)
-Zach
I'd like an advise on how to use custom controller in Visualforce Email Template.
Basically, I would create a Controller like this.
public class HourlyJobReport{ public List<job__c> JobList{get;set;} public HourlyJobReport() { JobList = new List<Job__c>(); JobList = [select name, status__c, duration__c, start__c from job__c where status__c = 'Dispatch' and Duration__c > 60]; } }
Then would reference the code to the Component like this.
<apex:component controller="HourlyJobReport" access="global"> <apex:dataTable value="{!JobList}" var="job"> <column value="{!job.name}"/> </apex:dataTable> </apex:component>
Then use the component in the Template like this.
<c:nameOfTheComponent>
This approach works great. But I'd like to have the Repeat tag in my visualforce Template Intead of using it in the Component. One reason is that when I do styling from the Component, the Style does not work when the Visualforce Email Template is Sent through email.
in the Preview of the VisualForce Page, it looks like this one below. (Note, I'm using style here from the Component that I have created for the custom controller)
But when it's sent to my email, it will look like just a plain text. Something like below.
Does anyway here encountered issues like this or have solution for this one?
Thanks a lot :)
-Zach
I got this one resolved now by adding the style Inline instead of putting the Style inside the <style> tag.
So the code looks like this.
Not sure but it seems that when using Custom Components, the styling drop off when the visualforce is sent to Email if the style is inside the <style> tag or External StyleSheet.
Thanks for helping out :)
-Zach
All Answers
Have a look at this -
https://developer.salesforce.com/page/VisualForceEmailTemplates_sample
http://www.vandeveldejan.com/the-not-so-scary-visualforce-email-template-as-order-confirmation-email/
I got this one resolved now by adding the style Inline instead of putting the Style inside the <style> tag.
So the code looks like this.
Not sure but it seems that when using Custom Components, the styling drop off when the visualforce is sent to Email if the style is inside the <style> tag or External StyleSheet.
Thanks for helping out :)
-Zach