Email Services in Salesforce

Email Services in Salesforce - Learn All About It

Salesforce Email Service is an automated process that processes inbound email using Apex classes. We need to create a separate email address for Salesforce to receive your emails when we set up an email service. To implement Messaging, we'll need to develop one apex class. The InboundEmailHandler interface is used to handle inbound emails. When an email is received at the email address, the email services will call the handleInboundEmail function on the Apex class.

Syntax:

global class myHandler implements Messaging.InboundEmailHandler {
    Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        return result; 
    }
}

dont miss out iconDon't forget to check out: One Must Opt For Salesforce Email Automation

Example:

Create a case using Email

 

global class CreateCase implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
          Case c = new Case();
          c.status = 'New';
          c.origin = 'Email';
          c.Type = 'Electrical';
          c.Subject='EmailServiceTocase';
          insert c;  
          result.success = true;
         return result;
     }
}

 

Creating Email Services in Salesforce:

1. To create a new email service, go to setup -> Email Service -> New Email Service.

2. Click on Save and New Email Address

Email Services

Email Services in Salesforce

3. Click on Save.

Salesforce generates an email address for yourself.

dont miss out iconCheck out another amazing blog by Sandeep here: Learn About Salesforce Einstein Prediction Builder

Testing Email Service:

Send an email to this address with the subject 'EmailServiceTocase'

A case will be created.

Governor Limits of Email Services:

The overall number of messages that Salesforce's email services, including On-Demand Email-to-Case, can process per day is limited. Depending on how you design the failed response settings for each email service, messages that exceed this limit are bounced, destroyed, or queued for processing the next day. The restriction is calculated by multiplying the number of user licences by 1,000, with a daily limit of 1,000,000.

Responses

Popular Salesforce Blogs