-
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
The ultimate guide to building up Opportunity Management in Salesforce
Once you’ve learned how to customize your Salesforce opportunity stages, you can consider enhancing opportunity management in Salesforce to improve visibility for sales managers and…
5 Reasons Why You Should Say ‘YES’ to Salesforce Mobile App
If you’re in sales, you know how crucial the customer relationship management (CRM) platform is to move dealings through the pipeline. You may have been…
Salesforce Public Cloud for Education
Digitalization has transformed the way we live and has made data effortlessly accessible in a world that is always on the go, and it has…
Popular Salesforce Videos
Salesforce Tutorial - What Is Data Loader
Generally, in the Declarative approach, developer enters data with page-layout, Data Loader is an amazing tool for bulk data processing. I have seen many migration…
What is Salesforce Hyperforce?
In this video, you will take a look at Salesforce Hyperforce, Salesforce's new re-architecting of the Salesforce platform. 00:00 Introduction 00:28 What is Salesforce Hyperforce?…
Salesforce Professional Services Helps Customers Get Value From Salesforce, Faster
Our experts have helped thousands of customers transform their businesses, operating models, and cultures, all backed by the full power of Salesforce. Watch this video…