-
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, 4 months ago by
Prachi.
-
This discussion was modified 6 years, 4 months ago by
Log In to reply.
Popular Salesforce Blogs
Salesforce Developer Day To Day Activities
Salesforce is the most in-demand and one of the fastest growing skills which you should possess if you want to have a career in the…
Running Metadata API in Apex as a specific user
Running Metadata API in Apex as a specific user Calling the metadata API in Apex requires admin permission or at least the "Modify All Data"…
CRM for FinTech: Why Choose Salesforce For Fintech Companies?
Recently German specialists of information technologies published the article “What determines FinTech success?—A taxonomy-based analysis of FinTech success factors”. They provided insights into the potential determinants…
Popular Salesforce Videos
Spring'21 Prior Value in Salesforce Record Triggered Flows - ISCHANGED IN Salesforce Flows
In this video, I'm talking about the Prior value feature in the Spring'21 pre-release that is for the record triggered flow. Pre-Release Org URL: https://www.salesforce.com/form/signup/prerelease-spring21/…
Rise & Shine with The Salesforce Women's Entrepreneur Group
The Salesforce Women’s Entrepreneur Group invites you to our first quarterly event of the year, Rise & Shine - Celebrating Women’s History Month. We are…
How to Prepare for Salesforce Platform App Builder (CRT-402) ?
The Salesforce Platform App Builder certification focuses on the different declarative functions available to an admin. Development and code are not included, but it focuses…