0

I am trying to create a VisualForce Email Template, in this emailTemplate i need to get value from Custom Objects.(This Object is not related to Any other Objects - This is the Object Which i am storing the Configuration values)

Below are the Apex Class, Controller, and VF Email Template. I am Receiving the empty data email.

APEX:

public class getSiteURL {
    private Configure__c config; 
    public string getSiteURL() {        
        config = [select Configuration_Value__c from Configure__c where Configuration_Type__c LIKE 'Site URL'];
        
        return config.PSAS__Configuration_Value__c;
    }    
}

VF Components -- siteURLComponents

<apex:component  controller="getSiteURL" access="global">
</apex:component>

VisualForce Email Template

<messaging:emailTemplate subject="test" recipientType="Contact" relatedToType="Family__c">
<messaging:htmlEmailBody >
<html>
<body>
<b><u>URL:</u></b>
        <br />
        <c:siteURLComponents/>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

1 Answer 1

1

In your component you need to use the variable you are not using it. Also I suggest you as better practice use Proper name for controller and follow proper naming conventions.

<apex:component  controller="getSiteURL" access="global">
    {!SiteURL}
</apex:component>
3
  • Thanks @tushar , Facing One more issue I am trying to add this string in href in the VF Email Template like this href='<c:siteURLComponents />/school?id={!relatedTo.key}' When I do the Send Test and Verify Getting link like this Qwertd-dev-ed.my.salesforce.com/email/%3Cc:siteURLComponents%20/… Commented Oct 23, 2020 at 13:03
  • I suggest you to create this anchor tag in component itself. Commented Oct 23, 2020 at 13:09
  • Tried by adding ` <a href="{!SiteURL}"></a>` in Component, Still facing same Issue. Commented Oct 23, 2020 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .