function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dlattedlatte 

Messaging.InboundEmail.TextAttachment method body.length() yields different results when attachment is sent from Outlook vs Gmail

I am sending the exact same attachment from Outlook or from Gmail.

My debug log files are showing my method that checks the body.length() of the TextAttachment yields different results.

In my code, I set the maxSize for my test toInteger =  5242880.

My method tests the body.length() < maxSize.

If the method correctly determines the attachment size is less than 5 MB, then I insert the attachment.

I have observed when my message and attachment is sent from  Outlook, the method 'incorrectly' determines the body.length < maxSize, and thus when the attachment tries to insert, Salesforce throws the error:

FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: MAXIMUM_SIZE_OF_ATTACHMENT, attachment data exceeded maximum size: [BodyLength]


However, if I send the exact same attachment via GMail, the body.length < maxSize method correctly assesses the size to be 5 MB, and then goes into my proper code so it does not try to insert the attachment.
Sonam_SFDCSonam_SFDC
Is it posible that the mail being sent from Outlook is being encrypted /signed which is incresing the size of the email when sent out?

Read the following while researching for this issue:
http://support.microsoft.com/kb/927092