-
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 ago by Prachi.
Log In to reply.
Popular Salesforce Blogs
Salesforce Lightning Experience: Tools for Transitioning from Salesforce Classic to Lightning
Introduction January 7, 2020: The date when good news finally arrived from Salesforce to its users that the company is auto activating Salesforce Lighting Experience…
Master Customer Relationships: Understand the Power of CRM Technology
Mastering customer relationships is the key to success in today's hyper-competitive business landscape. Customers are not just looking for products or services; they seek personalized…
Creating Reports in Salesforce: Most Important Aspects
The time has come. Your business begins to ask questions, and the data you have collected has the answers. You need the information to help…
Popular Salesforce Videos
Salesforce lightning customize record page: Build a Custom Record Page
Salesforce Lightning Experience comes with a slick user interface that is easy to navigate and even easier to use right from the beginning. Lightning is…
Salesforce Training Videos For Beginners - 3 | Salesforce Admin Training
This Salesforce Training Video will help us in quotation generation and improve customer communication. Generating proposals can be a drag on sales team productivity. Editing…
5 Reasons To Choose Marketing Automation For Your Business | Salesforce
With the advancement in technology, it has become imperative to move towards more advanced methods to grow your business. Marketing automation is one method that…