1

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]; 
    mail.setTemplateId(et.Id); 
    mail.setSaveAsActivity(false); 
    mail.setTargetObjectId(toId);
    mail.setWhatId(wId);
    // Use Organization Wide Address 
    for(OrgWideEmailAddress owa : [select id, Address from OrgWideEmailAddress]) {
        if(owa.Address.contains('noreply')) {
            mail.setOrgWideEmailAddressId(owa.id); 
        }
    }
    try {
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    } catch (Exception e) {
        System.debug(logginglevel.error,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');">

Why?

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

1 Answer 1

2

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

You must log in to answer this question.

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