Email to Case - On Demand
For Difference between Email to Case & Email to Case - on Demand click here
Setting Up Steps,
- Set the Default Case Owner and Automated Case Owner for your organization.
- Enable and configure Email-to-Case.
- Enable and configure On-Demand Email-to-Case.
- Configure your routing address settings to customize the way Salesforce handles your customer emails.
- Test your email routing addresses by manually sending emails to them and verify that these emails convert to cases based on their routing address settings.
- Add the email address that you configured to your company's support website. This is the email address customers can use to submit cases to your support team.
- Add the Emails related list to the Cases page layout.
- Optionally, create templates agents can use when replying to email. These templates can include merge fields that display information from the original email in the reply
Following Apex Class Handles email and Creates a case in Salesforce
global class CaseEmailHandler implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
//create result for email operation
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
//Creating case shell
Case c = new Case();
c.ContactId = <<Contact_Id>>; // populating case fields hardcode/you can query contact Id here
c.Status = 'New';
c.Subject = email.subject;
c.Description = email.plainTextBody;
c.RecordTypeId = '012300000005aUz'; // pass case recordTypeId
insert c; // Inserting Case
//Setting Result which would be helpful for debugging purposes
result.message = 'New Case Created';
result.success = true;
return result; // return Result
}
}
That's all, comment below If you need any help