function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raj R.Raj R. 

How to create link to custom object in apex class?


I am trying to use apex trigger to send an email when certain criteria is met for a customObj1__c. The email is supposed to include a link that is something along the lines of "". 

How can I send an email where there is a direct link to the record?


Subject: "Some subject"
Best Answer chosen by Raj R.
Tejpal KumawatTejpal Kumawat
Hello friend try this code :
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {

	'' //your email id
mail.setSubject('Some subject');
String mailBody = 'Link: '+ URL.getSalesforceBaseUrl().toExternalForm()+ '/'+customObjId;
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
Tej Pal Kumawat
Skype : tejpalkumawat1991

If this answers your question mark Best Answer it as solution and then hit Like!