I am working on email to case. My requirement is: Whenever a user send email from outside to salesforce generated email service address, case record should be created. After that user should receive reply in which case id is appended with email subject. Below is my which i have written so far.

global class TestEmail implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

    String caseNumber;

        Case caseObj= new Case();

        QueueSObject QueueID = [Select Queue.Id, Queue.Name, Queue.Type from QueueSObject WHERE 
                                Queue.Name ='Case Open Queue' Limit 1];

        insert caseObj;

        result.message='Thanks for sending mail';

        return result;


  • What is the issue you are having? Please edit your post to include the details. – David Cheng Feb 11 at 15:54
  • how to send mail back to user by appending case id in subject – Ashwani Kumar Feb 12 at 5:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.