-
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, 3 months ago by
Prachi.
-
This discussion was modified 5 years, 3 months ago by
Log In to reply.
Popular Salesforce Blogs

What is Salesforce Financial Services?
If you work in the financial sector and you like Salesforce as much as we do, it’s likely you’ve heard of the Financial Services Cloud.…

A Detailed Guide to Salesforce RPA Integration in 2023
Salesforce is one of the most popular CRM software in the world. There are a lot of benefits to using Salesforce, but one of the…

How Salesforce CPQ Can Enhance the B2B Customer Experience?
A typical B2B buying experience is known to be complex and heavily layered. With a prolonged quoting process and the lack of personalization in billing…
Popular Salesforce Videos
Salesforce Service Cloud Implementation
Salesforce Service Cloud offers a long list of powerful tools to help you realize the potential of your service team. With the endless opportunities for…
Salesforce Admin training : How to create a custom app in Salesforce?
In this tutorial, you will learn to create a custom app in Salesforce and go through a quick overview of Profiles. Profiles control the visibility of your…
How to Use Salesforce Process Builder 2017
Salesforce process builder is a powerful tool you can use to automate business processes. It has a simple interface that allows you to point and…