-
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, 10 months ago by
Prachi.
-
This discussion was modified 6 years, 10 months ago by
Log In to reply.
Popular Salesforce Blogs
Top 5 Feature Updates in Salesforce Spring ‘20 Release
Hello everyone and welcome to 2020! We hope you all enjoyed the holidays and had a nice new year! With a new year brings a…
File Upload in Lightning Web Component | Salesforce Lightning Tutorial
Users can upload many files quickly and easily with the lightning-file-upload component. Drag and drop capabilities and file type filters are also available in the…
Popular Salesforce Videos
Salesforce JavaScript Developer 1 Certification Series
Hi Everyone, SFDC Panther has started the Salesforce JavaScript Certification series and this is the first session. What you will learn: Variables Data Types Operators…
Salesforce Nonprofit Success Pack Implementation Guide
There are so many things to consider when using Salesforce Nonprofit Success Pack for your nonprofit organization that it can be tricky to know where…
How to Enable and Create the B2B Marketing Analytics App in Salesforce
This video will walk through the steps to enable Pardot B2B Marketing Analytics in Salesforce Setup, and the creation of the B2BMA app. Prerequisites and…