You need to sign in to do that
Don't have an account?
Sarthak Bhatnagar
Adding clickable text (hyperlink) in Apex Class
I have an Apex class that I am using as a custom controller to send an email from a VF page. In that class I have constructed the email subject and body to have predefined text but the user still has the option to edit/add on to it on the VF page.
PROBLEM: I am trying to add a link to the email body in the constructor in the Apex class so that the person receving the email can directly go the record that the email is refering.
This is an example of the body text:
String body = 'Hi ' + Contact.FirstName + ', \n' + 'This is the account I am talking about + (hyperlink) acc.Name + ' Lets discuss some more."
I have tried constructing a string with an href:
String link = '<a href="https://www.surveymonkey.com>' + acc.Name + '</a>';
But that just prints the whole string, along with the link, and doesn't make the acc.Name hyperlink.
I also tried adding a commandLink on the VF page between the body tags but that doesn't work either.
Any input is appreciated.
PROBLEM: I am trying to add a link to the email body in the constructor in the Apex class so that the person receving the email can directly go the record that the email is refering.
This is an example of the body text:
String body = 'Hi ' + Contact.FirstName + ', \n' + 'This is the account I am talking about + (hyperlink) acc.Name + ' Lets discuss some more."
I have tried constructing a string with an href:
String link = '<a href="https://www.surveymonkey.com>' + acc.Name + '</a>';
But that just prints the whole string, along with the link, and doesn't make the acc.Name hyperlink.
I also tried adding a commandLink on the VF page between the body tags but that doesn't work either.
Any input is appreciated.
Instead of using
'<br><br>'+<a href="https://www.surveymonkey.co.uk">Take the survey now.</a>+
try to add your link inside single quote like
'<br><br><a href="https://www.surveymonkey.co.uk">Take the survey now.</a>'+
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
@Sarthak Bhatnagar,
Did you get the solution ?
@Deepali, this doesnot work at all.