0

I have been trying to include Salesforce base URL along with some static information in the html body of the email but to no luck. I keep getting error "Error: Compile Error: Unrecognized symbol '"', which is not a valid Apex identifier.".

I have even tried to put all the information between the html tags, but that too din't helped.

    String body='';

    body += '<html></br> </br>' + 'For more details, please review the Case HERE: '+ 
    <a href="'+URL.getSalesforceBaseUrl()+'/'+instOfCase.id+'">'+instOfCase.CaseNumber+'</a>
    body +=  '</body></html>';

    mail.setHtmlBody(body);

Please suggest something.

  • Instead of this ->"'+URL.getSalesforceBaseUrl()+'/',,,,,try this "'" + URL.getSalesforceBaseUrl() + "'/' – Ysr Shk Jan 18 '18 at 4:01
2

I was just doing the exact same thing today. Do it like this...

String body='';

body += '<html></br> </br>' + 'For more details, '
     + 'please review the Case HERE: '
     + '<a href="'+URL.getSalesforceBaseUrl().toExternalForm()
     + '/' + instOfCase.id + '">' + instOfCase.CaseNumber 
     + '</a>';
body +=  '</body></html>';

mail.setHtmlBody(body);

Use

.toExternalForm()

to put this as a String in your URL - This will work for you!

Please see the Docs HERE for future reference.

Happy coding!

|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.