0

In My Apex Class am sending email to user once registration completed. in that email am sending the text with hylerlink as Click Here to Complete your Registration

Click Here click here should be the Hyper link. but in mail it's send as plain text

email.setHtmlBody('Hello ' + FirstName + '<br/><br/>Thanks for registering. This is your Member ID ' + contact.Member_ID__c+'.<br/><br/><a href='+URL.getSalesforceBaseUrl()+'/'+c.id+'>Click Here</a> to Complete your Registration');    

Kindly help me on this.

3

you need to use URL.getSalesforceBaseUrl().toExternalForm() to work url properly. It will solve your problem

email.setHtmlBody('Hello ' + FirstName + '<br/><br/>Thanks for registering. This is your Member ID ' + contact.Member_ID__c+'.<br/><br/><a href="'+URL.getSalesforceBaseUrl().toExternalForm()+'/'+c.id+'">Click Here</a> to Complete your Registration');
0

I think you can use toExternalForm() method of URL Class to solve this issue

toExternalForm() :Returns a string representation of the current URL.

Example: String MySFURL = URL.getSalesforceBaseUrl().toExternalForm(); this will return your salesforce URL as a string.

So you can try this:

 email.setHtmlBody('Hello ' + FirstName + '<br/><br/>Thanks for registering. This is your Member ID ' + contact.Member_ID__c+'.<br/><br/><a href='+URL.getSalesforceBaseUrl().toExternalForm()+'/'+c.id+'>Click Here</a> to Complete your Registration');  

OR
  email.setHtmlBody('Hello ' + FirstName + '<br/><br/>Thanks for registering. This is your Member ID ' + contact.Member_ID__c+'.<br/><br/><a href="'+URL.getSalesforceBaseUrl().toExternalForm()+'/'+c.id+'">Click Here</a> to Complete your Registration');  

Both of the code should work.

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.