-
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, 1 month ago by
Prachi.
-
This discussion was modified 6 years, 1 month ago by
Log In to reply.
Popular Salesforce Blogs
Need to Hire Salesforce Developers-in-House? 5 reasons Why it is a Bad Idea!
Glancing through Salesforce customer reviews, you may have noticed how often companies are surprised - and even shocked - about what comes after Salesforce implementation.…
Apex Trigger In Salesforce - The Developer Guide
Apex Trigger in Salesforce A trigger is an Apex script which executes before or after DML events occur. Apex triggers enable you to work on…
How to use apex:actionFunction and apex:actionStatus in Salesforce Visualforce Page?
How to use apex:actionFunction and apex:actionStatus in visualforce page ? apex:actionFunction - It provides support for calling an apex method from JavaScript code using an…
Popular Salesforce Videos
Survival Kit for Beginner Salesforce Developers - 1
Are you a developer just starting out with Salesforce? Are you an admin looking to get into development? Join us to learn a few easy,…
Drive Personalized and Scalable Idea Management in Salesforce Community Cloud with IdeasPro
IdeasPro enables you to implement the best of business ideas from your Salesforce community. Foster innovation, improve brand transparency, and make the most of internal…
Get Started with Admissions Connect | Salesforce Tutorial
Ready to simplify the application process and streamline the work of your admissions professionals? Enter: Admissions Connect! This is the purpose-built product built natively on…