-
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 6 years, 11 months ago by
Prachi.
-
This discussion was modified 6 years, 11 months ago by
Log In to reply.
Popular Salesforce Blogs
Salesforce Einstein Copilot
Salesforce continues to push the boundaries of customer relationship management (CRM) with its innovative technologies. One of the latest advancements is Salesforce Einstein Copilot, an…
What are Campaigns in Salesforce in 2023?
One of the most important features of Salesforce is its Campaign feature, which allows businesses to plan, execute, and track marketing campaigns. A campaign in…
Commonly Made Mistakes in Salesforce Integration and How One Can Avoid Them
Hey you all, Bienvenue to my blog which is going to tell you about Integration and what few common mistakes occur at the time of…
Popular Salesforce Videos
Salesforce Public Groups and Queues
In this video, Bhavesh Jain demonstrates how to create Salesforce public groups and how they can be used, as well as provides an understanding of…
How to Create a Free Developer Account in Salesforce?
There are many ways of creating a Salesforce account without investing a single rupee or a dollar with the developer’s edition and working on the…
How to Set Up a Journey in Journey Builder
Learn to build a customer journey with guidance from our experts. This video provides an overview of Journey Builder features and best practices. Get expert…