You need to sign in to do that
Don't have an account?
donob
Adding a link to HTML body when sending an email alert via apex
I'm trying to send an email that includes a link to a record in Saleforce using apex email alert and the setHtmlBody method. I'm trying to send the link like so..
<a href="'+URL.getSalesforceBaseUrl()+'/'+workOrder.id+'">'+workOrder.Name+'</a>
The email gets sent out just fine, but the link isn't there. When I look at the source in the email it shows the a tag without the href attribute like so...
<a>Work Order Name</a>
Can anybody tell me why this is happening and what I can do to get the link to work?
Thank you digamberlucky for your reply. I did as you suggested and wrapped the <html></html> tags around the body, unfortunately it didn't solve the problem. I did however figure out what was wrong.
The method URL.getSalesforceBaseUrl() showed up as
To get it to work I had to do URL.getSalesforceBaseUrl().toExternalForm() which made the link show up properly as href="https://my.salesforce.com"
All Answers
Hi,
The body which you are creating should also be wrapped around <html></html> tag.
Something like below:-
Let me know if you still have any question.
Happy to help you!
Thank you digamberlucky for your reply. I did as you suggested and wrapped the <html></html> tags around the body, unfortunately it didn't solve the problem. I did however figure out what was wrong.
The method URL.getSalesforceBaseUrl() showed up as
To get it to work I had to do URL.getSalesforceBaseUrl().toExternalForm() which made the link show up properly as href="https://my.salesforce.com"
Where opp is the opportunity's instance.