I have an email template that includes a commandLink. This utility method is used to send the email.

public static Boolean sendEmailTemplate(String tNm, Id toId, Id wId) {

    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    EmailTemplate et = [SELECT id from emailtemplate where name= :tNm]; 
    // Use Organization Wide Address 
    for(OrgWideEmailAddress owa : [select id, Address from OrgWideEmailAddress]) {
        if(owa.Address.contains('noreply')) {
    try {
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    } catch (Exception e) {
        return false;
    return true;

The email template includes a commandlink. When I execute this from anon apex (subbing in IDs for the params) it works like a charm. However, when I execute it from my application, the email is sent, but the link doesn't work. In looking at the logs, the log from the anon apex has a normal href tag:

<a href="www.salesforce.com">

but in the application log it is resolved as

<a href="javascript:srcUp('www.salesforce.com%3Fisdtp%3Dvw');">


  • Just use standard html a tag instead of apex:commandlink to force it to resolve to a url. – Adrian Larson Jan 21 '15 at 20:11

Use standard html a tag instead of apex:commandlink to force it to resolve to a url.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.