-
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, 2 months ago by
Prachi.
-
This discussion was modified 6 years, 2 months ago by
Log In to reply.
Popular Salesforce Blogs
Best SMS App for Salesforce: Features and Benefits
In today’s time, companies are supposed to keep their customers updated with every little bit of information. They must thrive on quick, effective, and seamless…
Maximize Your Salesforce Investment With Our Custom Solutions
For any business, small or big, providing great customer service determines its success. Salesforce is a full-fledged ecosystem that enables you to connect with your…
Engaging User Communities with Salesforce Experience Cloud
For years, Salesforce customers have leveraged communities to deliver Salesforce-powered interactions to their users. However, these communities were limited to singular portals and websites. In…
Popular Salesforce Videos
How to Manage Your Data and Contacts in Salesforce Marketing Cloud
Learn how contacts are counted and how data is structured in Marketing Cloud. This video explores how Marketing Cloud receives data from many sources and…
Process Builder In Salesforce | Tutorial Video
Do you want to create a record for any object from a workflow? Do you want to call your Apex class from a workflow? Do…
Salesforce DX Keynote: Continuous Development on the Lightning Platform
Calling all developers for a deep dive into how everyone, whether you click or code, can build on the Lightning Platform! Join us and learn…