-
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 4 years, 5 months ago by Prachi.
Log In to reply.
Popular Salesforce Blogs
Salesforce Veruna Implementation: Perfect Combo for Insurance Industry
Salesforce Veruna helps insurance agencies manage their sales processes and customer relationships. It is a comprehensive solution that enables agencies to increase efficiency and productivity…
Top 5 Salesforce Summer ‘20 Release Features That Skyrocket Productivity
Salesforce has just published its’ release notes for Summer ’20! It’s packed with a plethora of enhancements and newly introduced features for Salesforce clouds and…
What To Do When Salesforce Apex Heap Size Increases?
Welcome to Salesforce! You've just encountered your first governor limit . The 'Apex heap size too large' error occurs when too much data is being…
Popular Salesforce Videos
Salesforce Field Service Scheduling Optimization | AblyPro Webinar
Revolutionize and Level Up Your Game in Services Business With Field Service With Salesforce Field Service on your side, businesses can reduce travel time, improve…
What Role Can Salesforce Industries Play in Helping Various Sectors Grow?
Discover more about what role can Salesforce Industries play in helping various sectors grow then have a glance at this extract from our latest webinar!…
Security in Salesforce | Security Levels in Salesforce | Salesforce Training
This "𝐒𝐞𝐜𝐮𝐫𝐢𝐭𝐲 𝐢𝐧 𝐒𝐚𝐥𝐞𝐬𝐟𝐨𝐫𝐜𝐞" video by Edureka will help you understand the different levels of security in Salesforce. It will also talk about some of…