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
Millie WiseMillie Wise 

Error message when emailing invoice

When I click "email PDF" on the sales invoice I receive an error message:

SIN003349 - SendEmail failed. First exception on row 0; first error: STRING_TOO_LONG, Content Type: data value too large: application/pdf; name="=?ISO-8859-1?B?QlNIIEV2IEFsZXRsZXJpIFNhbmF5aSB2ZSBUaWM=?= =?ISO-8859-1?B?YXJldCBBLj8uIEludm9pY2VTSU4wMDMzNDkucGRm?=" (max length=120): [ContentType]
Max Bechdel 6Max Bechdel 6
We're receiving this error as well, and in our case, it's related to translatable fields in the email's attachment filename. Unfortunately, in our sandbox we can't reproduce. We also can't reproduce on production with the test email template feature.

We even wrote some code to test the string length in its encoded form, and make sure that doesn't go over 100 characters, yet we still receive the error. I'd be super stoked if you figured this one out! Thanks! I'll also try and post here if I make any headway.

Here is our apex to attempt to keep the string name small, which may/may not help you:
// fileName is just a string with the planned email attachment filename
// next, convert to blob and encode, make sure the length is under 100 chars, if not, keep making it smaller until it works
Blob fileNameBlob = Blob.valueOf(fileName + '.pdf');
String fileNameEncoded = EncodingUtil.base64Encode(fileNameBlob);

while (fileNameEncoded.length() > (100)) {
    fileName = fileName.subString(0, fileName.length() - 1);
    fileNameBlob = Blob.valueOf(fileName + '.pdf');
    fileNameEncoded = EncodingUtil.base64Encode(fileNameBlob);
}

fileName = fileName + '.pdf';
return fileName;