Email Services in salesforce are automated processes that use apex classes to process details or content in the Email. When you have to send or receive some email from external systems then we can use email services in Salesforce. There are two types of Email Services in salesforce. They are Inbound Email Services and Outbound Email Services(already discussed in one of our blogs).
Inbound Email Services:
Emails received from external systems to salesforce use apex class to retrieve details and attachments in the email. Apex classes use the InboundEmail object to process the email.For example, we can create an email service that automatically creates account records based on the account information received in the Inbound Email.
How to Create Inbound Email Service:
Click on Setup--> Build--> Develop--> Email Services
Before creating Email Services, Create Apex classes that implement the Messaging.InboundEmailhandler interface. Using the handleInboundEmail method in that class, you can access an InboundEmail object to retrieve the contents, headers, and attachments of inbound email messages, as well as perform many functions.
Apart from Messaging.InboundEmailhandler, there are some predefined classes under Messaging Namespace.
InboundEmail.Header Object
InboundEmail.BinaryAttachment Object
InboundEmail.TextAttachment Object
InboundEmailResult Object
InboundEnvelope Object
After Creating Apex Classes based on requirement, Create an Email Service:
Note: Before enabling this option, make sure that your users’ email domains support at least one of the following protocols: SPF, Sender ID, or DomainKeys. When this option is enabled, salesforce.com uses these protocols to verify the legitimacy of the email sender's server. If the server passes at least one protocol and does not fail any, salesforce.com processes the email. If the server fails a protocol or does not support any of the protocols, then salesforce.com does not process the email.