Apex Email Services message restrictions | Salesforce Developers Blog

What are the different size limitations for Apex Email Services?

There are some limits on what data and data sizes can be used
for Email Services. This post will explain how some of these limits

  • The max email message size for a complete email message including attachments is 10MB
  • Emails which are below 10MB will be accepted by our mail server
  • Email which are above 10MB will be rejected and an email response sent back to the sender

There are two separate parts of an email body

  • Text Body of the email can max be 100KB
  • HTML body of the email can max be 100KB

There are 2 types of attachments which can be retrieved via Email
Services, they are exposed as an array of text attachments and an array
of binary attachments.

  • Text attachments can be 100KB each
  • Binary attachments can be up to 5MB per attachment

Attachments are presented to the Apex code of an Email Service in two different forms:

  • Attachments that are labeled as "text" are presented
    as an Apex String and can be a maximum of 100KB each. A "text"
    attachment is any attachment whose Mime type is "text/*". For example
    "text/plain", "text/html", etc.
  • Attachments that are not labeled as "text" are presented as an Apex Blob and can be up to 5MB per attachment.

When all the elements, text body, HTML body, text attachments and
binary attachments are added together the total size of the email
message has to be below 10MB

  • Attachments that are themselves an email are presented to the Apex code of an Email Service in two different forms:
  • The "raw" text of the entire embedded email, including
    all headers, Mime delimiters, Mime encoded attachments, etc. is
    presented to your Apex code in the binary attachments list as a Blob.
    This attachment has a Mime type of "message/rfc822". Often attachments
    of this Mime type can be discarded by the Email Service.
  • Attachments to the embedded email are "pulled out" and
    stored in the text and binary attachment lists of the main email as if
    they had been directly attached.
  • If the message size limit is reached, a bounced notification
    email will be sent back to the sender, showing that the message size is
    above the acceptable limit we have in place.

More info

Stay up to date with the latest news from the Salesforce Developers Blog