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

Custom Controller Issue for Component in Visualforce Email Template

I have been searching and googling like crazy trying to resolve this. I wrote an email template with a component and custom controller, but I can't get any of the values set in the controller to show up when I try to test it via the Send Test and Verify Merge Fields button. I've read many posts here in this forum about this issue and have implemented everything I read but I'm STILL not getting anything, so there must be something else I'm missing.


Email Template

<messaging:emailTemplate subject="How Did We Do?" recipientType="Contact" relatedToType="SVMXC__Service_Order__c">
<messaging:htmlEmailBody >
    <style type="text/css">
        body {color:black; font-family:arial; font-size:12px}
        Hello {!Recipient.Name},<br/><br/>
        <c:SurveyEmailComponent_MEC emailWOId="{!relatedTo.Id}"/>



<apex:component controller="SurveyEmailController" access="global">
    <apex:attribute name="emailWOId" description="Passes the ID of the WO to the custom controller" type="Id" assignTo="{!woID}"/>
    <apex:outputText >We want to continue to improve by learning how we did on our recent service completed for you on {!completedDate}.<br/><br/>
    We would be grateful if you took 2 minutes to complete a very short survey by clicking the link below:
    <apex:outputLink value="{!contactID}&wf=yes">Service Follow Up Survey</apex:outputLink><br/><br/>
    <apex:outputText >Thank you,<br/>
    <apex:image value="{!photoURL}"/>



public class SurveyEmailController {
    public ID woID {get; set;}
    public SVMXC__Service_Order__c wo {get; set;}
    public ID contactID {get; set;}
    public String techName {get; set;}
    public String photoURL {get; set;}
    public String completedDate {get; set;}
    public SurveyEmailController() {
    public SVMXC__Service_Order__c getWO() {
        wo = [SELECT Id, SVMXC__Contact__c, Technician_completed_WO_Date_Time__c, SVMXC__Group_Member__r.Name, SVMXC__Group_Member__r.SVMXC__Salesforce_User__r.SmallPhotoUrl
              FROM SVMXC__Service_Order__c
              WHERE Id = :woID];
        return wo;
    public String getPhotoURL() {
        photoURL = wo.SVMXC__Group_Member__r.SVMXC__Salesforce_User__r.SmallPhotoUrl;
        return photoURL;
    public String getCompletedDate() {
        datetime techCompDate = datetime.valueOf(wo.Technician_completed_WO_Date_Time__c);

        if(techCompDate != null) {
            completedDate = techCompDate.format('MM-dd-yyyy', 'PST');
        } else {
            completedDate = System.Now().format('MM-dd-yyyy', 'PST');
        return completedDate;
    public ID getContactID() {
        contactID = wo.SVMXC__Contact__c;
        return contactID;
    public String getTechName() {
        techName = wo.SVMXC__Group_Member__r.Name;
        return techName;