-
Test Class for Inbound Email Service
I have written following inbound email service for lead object
global class LeadServices implements Messaging.InboundEmailHandler
{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
{
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
string emailbody = email.plaintextbody;
string emailsubject = email.subject;
string subToCompare = emailsubject.Substring(emailsubject.indexof('ref :') + 5).trim();
try
{
lead l = [SELECT Id, Name,Email FROM lead WHERE id = : subToCompare];
Task newTask = new Task();newTask.Description = emailbody;
newTask.Priority = 'Normal';
newTask.Status = 'Inbound Email';
newTask.Subject = emailsubject;
newTask.IsReminderSet = true;
newTask.ReminderDateTime = System.now();
newTask.WhoId = l.Id;
Insert newTask;
}
catch(QueryException e)
{
System.debug('Issue: ' + e);
}
result.success = true;
return result;
}
}
I am have having 55% code coverage now.
Can someone please hepl me with test class for this?- This discussion was modified 5 years, 1 month ago by Prachi.
Log In to reply.
Popular Salesforce Blogs
Salesforce Education Cloud Winter '25 Highlights
The future of education is here, and Salesforce is leading the charge with its latest Winter '25 Education Cloud updates. These updates will revolutionize the…
Salesforce Quoting Software: 9 Signs It’s Time to Consider a CPQ Solution
Are pricing errors or inconsistencies causing delays or customer dissatisfaction in your quoting process? Does generating a quote or proposal take too long due to…
The Importance of a Salesforce Consulting Company in Achieving Business Objectives
Introduction A Salesforce development company simply put, is a company that helps piece multiple fragments of a business together, helps in centralized data flow and…
Popular Salesforce Videos
Marketing Cloud | Salesforce Send Email
There are two ways to send an email in Marketing Cloud; Guided Send Wizard & Salesforce Send Email. The benefit of the Salesforce Send Email…
How to Become Salesforce Developer | Salesforce For Beginners
In this how-to become Salesforce developer video, you will be learning what is Salesforce, the fundamentals of Salesforce, how to become a Salesforce developer, how…
Introduction to Salesforce OmniStudio | Salesforce Industries
Introduction to Salesforce OmniStudio: The Salesforce OmniStudio digital engagement suite makes it easy to click-configure rich, consumer-grade user experiences based on objects, APEX classes, REST…