-
In below code snippet in Salesforce, what is going wrong?
In below code snippet,
trigger TestBeforeDelete on Lead (before Delete) { for(Lead l : Trigger.Old) { l.addError('error'); } String msgBody = 'Test Email'; String Subject = 'Test from Cogni Force on Lead'; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {'abc@gmail.com'}; mail.setToAddresses(toAddresses); mail.setReplyTo('abc@gmail.com'); mail.setSenderDisplayName('Cogniforce Test Simulator'); mail.setSubject(Subject); mail.setPlainTextBody(msgBody); mail.setHTMLBody(msgBody); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); }What is your observation and what is going wrong?
Log In to reply.
Popular Salesforce Blogs
Manual Sharing Using Apex in Salesforce - Best Practices
Apex Managed Sharing Sharing rules, they enable us to make exceptions to organization wide defaults for certain users as per our requirement.We cannot make give…
Exceptional Salesforce Platform-App-Builder Exam Questions [2025] - Easiest Prep Solution
How to Prepare for Salesforce Platform-App-Builder Certification With ExamsHome Questions Preparing for the Platform-App-Builder certification can be a challenging task but with the right approach…
Hire Salesforce Partner for End-to-End CRM Success: Why the Right Expertise Matters
As businesses continue to scale and adapt to changing customer demands, the need for a powerful, flexible CRM ecosystem has never been greater. Salesforce remains…
Popular Salesforce Videos
What is a Salesforce Admin?
Salesforce administrators are the gatekeepers of their employer's sales and marketing data. They create each user account and determine the proper level of access based…
Top 6 Products by Salesforce Marketing Cloud
Salesforce is largely regarded as the most influential Salesforce automation and cloud CRM vendor, having popularized the SaaS model and, in the process, disrupted the…
Run UI Tests with UTAM | Salesforce Developer Tutorial
Testing apps is critical to ensure quality and there are different types of tests such as unit tests, integrations tests or end-to-end tests just to…