How does Email-to-Case transform customer email correspondence into structured support cases?
Answer
Basics: Customers prefer emailing support@company.com. Email-to-Case gives each support mailbox a Salesforce routing address; every email creates a case (or updates an existing one if it is a reply), maps the sender to a Contact, and keeps the conversation inside the case so nobody works from a shared inbox.
How it works: Setup > Email-to-Case > enable; create Routing Addresses (name, email address, case priority, origin, owner or queue, record type, task options). Salesforce verifies the address and generates a unique Email Services address; you forward your mailbox to it. An inbound message creates a Case (Origin = Email), an EmailMessage (with Incoming = true), and saves attachments as Files or Attachments on the message. Agents reply from the Case Feed email action; replies are threaded using a thread ID or email headers. Assignment rules, auto-response rules and Flows then fire as normal.
Advanced / deep dive: Two variants: On-Demand Email-to-Case (cloud, recommended) and the legacy Email-to-Case Agent (installed behind your firewall). Reply threading can use the thread ID token in the subject or body and the email headers (Message-ID, References); header-based threading is more resilient. Use Flow or an Apex trigger on EmailMessage (after insert, where Incoming = true) for classification, auto-tagging or deflection. Limits exist on email size and daily volume (verify current values in the docs). Protect against spam and loops with auto-response rules, sender filtering, and "do not reply to auto-replies" logic. Use Enhanced Email so messages are stored as Salesforce records and can be related to other objects.
Code / config example:
// Trigger handler idea: tag new email-origin cases by keyword (bulk-safe)
{
Map<Id, String> subjByCase = <Id, String>();
(EmailMessage m : newMsgs) {
(m.Incoming && m.ParentId != && m.ParentId.getSObjectType() == Case.SObjectType) {
subjByCase.put(m.ParentId, m.Subject);
}
}
List<Case> toUpdate = <Case>();
(Id cid : subjByCase.keySet()) {
(String.isNotBlank(subjByCase.get(cid)) && subjByCase.get(cid).containsIgnoreCase()) {
toUpdate.add( (Id = cid, Reason = ));
}
}
(!toUpdate.isEmpty()) update toUpdate;
}