How to get consistent email size (content + attachments) in Graph API

Andrew Earl 105 Reputation points
2024-09-16T14:22:23.3933333+00:00

Hi, I am using https://graph.microsoft.com/v1.0/me/messages/{{ID}}?$expand=singleValueExtendedProperties($filter=id eq 'Integer 0xe08') to get the size of an email (content plus attachments).

However, the 0xe08 value is consistently larger than the size of the email in Outlook. E.g.

  1. For an email with no content and two 10MB attachments plus one 9.9MB attachment I would expect the size to be 29.9MB. However the 0xe08 value returned by the API is 35479932 i.e. 33.8MB
  2. For an email with no content and two 14.95MB attachments, again I would expect the size to be 29.9MB. However the 0xe08 value returned by the API is 34,113,831 i.e. 32.5MB

Can you let me know

  1. Why does 0xe08 not match the email size?
  2. Why would the two emails in my example have different 0xe08 values when I would expect them to be the same?
  3. Is there is a more reliable way to get the email size?

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,943 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 1,750 Reputation points Microsoft Vendor
    2024-09-17T12:52:13.08+00:00

    Hello Andrew Earl,

    Thank you for reaching out to Microsoft Support!

    The discrepancy you’re seeing with the 0xe08 value compared to the expected email size can be attributed to several factors:

    Encoding Overhead: Emails are often encoded in a format like Base64, which increases the size of attachments by approximately 33%. This could explain why the size reported by the API is larger than the sum of the attachments’ sizes.

    Email Headers and Metadata: The size reported by the 0xe08 property includes not just the content and attachments, but also the email headers, metadata, and any additional properties stored with the email. This can add to the overall size.

    Storage Format Differences: The way email content is stored on the server might differ from how it’s represented in the client application (Outlook), leading to size variations.

    Why the Two Emails Have Different 0xe08 Values

    Even if the total attachment size is the same, differences in the email content, headers, and other properties can lead to variations in the reported size. Each email might have different metadata, headers, or even slight differences in how the attachments are encoded.

    More Reliable Way to Get Email Size

    If you need a more precise measurement of the email size, you might consider:

    • Calculating the size manually: Sum the sizes of the email content and attachments, and then add an estimated overhead for encoding and metadata.
    • Using the PR_MESSAGE_SIZE property: This property might give you a closer approximation to the size as seen in Outlook, though it still includes some overhead.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.