Activity Forums Salesforce® Discussions Test Class for Inbound Email Service

  • Test Class for Inbound Email Service

    Posted by Prachi on November 11, 2019 at 6:14 pm

    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, 1 month ago by  Prachi.
    Piyush replied 5 years, 1 month ago 2 Members · 1 Reply
  • 1 Reply
  • Piyush

    Member
    November 12, 2019 at 5:45 am

    Hi,

    Please send your Test class with 55% code coverage. Then we will try to help you in your test class.

    Thank you

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos