I don't know if I'll ever be good enough to understand the real reason for this, but I did find a solution to my problem.
As I write this, I realise that I'm also using MimeKit v4.8.0 while v4.11.0 is available. Not yet tested on v4.11.0
Essentially the problem seems to occur when:
Email stream is read into a new MimeMessage
WriteTo is called on that MimeMessage to write to a new stream / byte array
A new MimeMessage is created from this new stream / byte array
The solution (in my case at least) was to store the original byte array only, and not to store or reuse the output of the MimeMessage.WriteTo() method.
But again, I only hit this problem on a Linux box (Windows seemed fine), and the ONLY difference I could find (on a byte-for-byte basis) between the mails that worked and didn't work was the line endings (\r\n worked; \n did not work).
The thing was that causing all of those weird equals signs was some sort of off-by-one issue when handling the line breaks and/or line lengths.
For example, given the below 2-line snip of "quote-printable" section of the message (have added the \r\n characters for clarity):
<div lang=3D"EN-US" link=3D"#467886" vlink=3D"#96607D" style=3D"word-wrap:b=\r\n
reak-word">
this SHOULD be extracted / translate to:
<div lang=3D"EN-US" link=3D"#467886" vlink=3D"#96607D" style=3D"word-wrap:break-word">
but INSTEAD was getting extracted / translated to:
<div lang=3D"EN-US" link=3D"#467886" vlink=3D"#96607D" style=3D"word-wrap:b=eak-word">
In other words, it was keeping the "=" at the end of each line, and dropping the first character from the subsequent line. This obvious broke the HTML structure, and if it was actual content that was spanning the line break, you'd see characters being "replaced" by "=" signs.
For good measure, some commented code that illustrates the issue I was seeing:
// Gets the message stream from Microsoft Graph API
var mimeContentStream = await _Client.Users[_Username].Messages[uid].Content.GetAsync();
// Loads the message stream into a MimeMessage object
// write this mimeMessage to disk / view in email client, and I get the correct body
var mimeMessage = await MimeKit.MimeMessage.LoadAsync(mimeContentStream);
// writes the MimeMessage object to a byte array
byte[] mimeMessageArr;
using (var ms = new MemoryStream())
{
mimeMessage.WriteTo(ms);
mimeMessageArr = ms.ToArray();
}
// Loads the byte array into a new MimeMessage object
MimeMessage mimeMessageAgain;
using (var ms = new MemoryStream(mimeMessageArr))
{
mimeMessageAgain = await MimeKit.MimeMessage.LoadAsync(ms);
}
// write mimeMessageAgain to disk / view in email client, and I get lots of EQUALS signs interspersed with the (mis-formatted) body
I don't think the fact that I was retrieving this from a Microsoft Graph API call makes the difference. I have no idea why Linux/Windows would make a difference. All I know is that after 2 days I can finally sleep.