-
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 ago by
Prachi.
-
This discussion was modified 6 years ago by
Log In to reply.
Popular Salesforce Blogs
Learn All About Batch Apex Chaining in Salesforce
Batch apex enables the user to do a single job by breaking it into multiple chunks which are processed separately. Batch apex is useful when…
Triggers in Salesforce - All You Need to Know
Trigger A trigger is a piece of code that runs before and after a record in the force.com database is inserted, updated, or deleted. Triggers…
To Lead or not to Lead, that is the question! | Salesforce Guide
Back when things were normal and we were able to go on-site and talk with our clients, there were a significant number of them who…
Popular Salesforce Videos
Salesforce Workflow vs Process Builder | Salesforce Tutorial
This "Salesforce Workflow vs Process Builder" video by Edureka will firstly help you understand what exactly is Salesforce workflow and what is Salesforce process builder.…
Secrets and Tips on Marketing Automation in Marketing Cloud | Marketing Cloud Webinar by Vimera
Hi there! Welcome to the recording of our Marketing Cloud Webinar from September 30, 2024! At Vimera (vimera.io), we’re proud to be a trusted Certified…
How to Delete Preloaded Sample Data in New Salesforce Organizations
When Users begin a trial or subscription with Salesforce, their org comes with a set of sample data. This data includes Accounts, Contacts, and Opportunities.…