That makes sense and yeah, htmlToText() can get pretty messy with all the spacing and structural tags depending on how complex the email formatting is!
Just to clarify one important architectural detail, because this is usually where the hidden trap lies:
- You are absolutely right that standard attachments (PDFs, Excel files, etc.) live in a separate array and do not affect the body size at all.
- However, inline images (like company logos in signatures or pasted screenshots) behave differently. Outlook converts those images into massive Base64 text strings and embeds them directly inside the email body HTML
- (looking like <img src="data:image/png;base64,...">).
That is why a short, 2-line email with a single pasted screenshot can silently blow up to 150,000+ characters. Even though you don’t see the contentBytes property in the body text, that massive payload is still physically sitting inside the HTML string, which is what chokes the SharePoint write action.
Because it is part of the string, truncating the body length actually will protect your flow from crashing.
Two Practical Paths Forward
If htmlToText() is outputting too much junk, here are the two most reliable enterprise patterns for this scenario:
The Safe Truncate Check (Keeps HTML layout, caps length):
You can use an expression to check the length of the body. If it's too large, truncate it to 50,000 characters to keep it safe for SharePoint; if it's small, let it pass through normally:
if(greater(length(triggerBody()?['Body']), 50000), substring(triggerBody()?['Body'], 0, 50000), triggerBody()?['Body'])
Separate the Storage (Highly Recommended):
Use a Create file action to save the raw email body directly into a SharePoint Document Library or OneDrive folder as an .html file. Then, just patch a hyperlink to that file into your SharePoint list. This completely preserves the original email layout (images included) without bloating your list rows.
Good luck with the rest of your experimenting! Let me know if either of those options does the trick for you.