How to get Salesforce base/domain url in Visualforce Email template?

How to get Salesforce base/domain url in Visualforce Email template?

URL.getSalesforceBaseUrl().toExternalForm() can be used in Salesforce Apex to get the base or domain URL.

Sample Code:

System.debug(
    'Base or Domain URL is ' +
    URL.getSalesforceBaseUrl().toExternalForm()
);

Use the following method in the controller to get Salesforce base url in Visualforce Email template.

public String getfullURL() {  
     return URL.getSalesforceBaseUrl().toExternalForm();
}

fullURL variable can be used in the Visualforce Email Template.

One thought on “How to get Salesforce base/domain url in Visualforce Email template?

Leave a Reply