# How does On-Demand Email-to-Case differ from traditional email server integration setups?

**Topic:** Service Cloud · **Difficulty:** Medium · **Tags:** Service Cloud, Email-to-Case, Cloud Infrastructure

Read it on the site: https://www.forcechallenges.com/interview-questions/how-does-on-demand-email-to-case-differ-from-traditional-email-server-integration-setups

## Answer

**Basics:** Both features convert inbound email to cases. The difference is where the mail is picked up. With On-Demand, you forward your support mailbox to a Salesforce-generated address and Salesforce does the rest. With the Agent, a small Java application inside your firewall connects to your email server (IMAP or POP) and sends messages to Salesforce. (The original "On-Demand Email-to-Service" name is not a Salesforce feature; it is On-Demand Email-to-Case.)

**How it works:** On-Demand: Setup > Email-to-Case > Enable On-Demand Email-to-Case, create a Routing Address, verify it through the confirmation email, then set up forwarding from your mailbox to the generated Email Services address. Agent: download and install the agent, configure the mail server connection and the Salesforce login, and keep the machine running. The agent's use is mainly for organizations that cannot forward mail outside their network.

**Advanced / deep dive:** On-Demand is simpler, scales with Salesforce, has no server to patch and supports Enhanced Email and header-based threading; Salesforce recommends it for new implementations. The Agent offers control for strict network policies but adds operational risk (downtime, upgrades, credentials) and is legacy, so confirm current support status before choosing it. Both are subject to attachment and size limits and to daily processing limits on inbound email, which depend on licenses (verify current numbers). If you need custom parsing, you can instead use Email Services with an Apex class implementing `Messaging.InboundEmailHandler`, but then you build case creation, threading and attachments yourself. Security considerations: restrict forwarding to the generated address, enable SPF/DKIM/DMARC at your mail provider, and use the authorized sender settings to limit who can create cases.

**Code / config example:**
```apex
// Custom alternative: Email Services handler that you build yourself
global class SupportInbound implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env) {
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    insert new Case(Subject = email.subject, Description = email.plainTextBody, Origin = 'Email', SuppliedEmail = email.fromAddress);
    result.success = true;
    return result;
  }
}
```

**Hidden gotchas & must-remember points:**
- Routing addresses must be verified before they process any email.
- The generated address changes after a sandbox refresh; forwarding must be updated.
- Forwarding can rewrite headers; test that From and threading work correctly.
- The Agent needs a persistent server and must be kept current.
- Email Services has its own limits and is not a drop-in replacement for Email-to-Case.
- Daily inbound limits apply; over-limit emails are rejected or deferred depending on settings.

**Best practice:** Choose On-Demand Email-to-Case unless network policy truly blocks forwarding, and test threading and attachments before go-live.

---
Source: ForceChallenges · last updated 2026-11-02
