After looking into a supplied .EML file, it turned out the issue is different than what I originally thought.
The .EML file was not an old-style RFC822 message, but a broken MIME message that actually violates both not only RFC 822, but its newer versions (RFC 2822, RFC 5322) as well:
- It uses wrong end-of-line sequence (0A instead of 0D 0A).
- It contains an empty line at the beginning – before the actual headers (an empty line indicates end of headers and can't be the first line in a file because header-less messages are invalid).
To fix the message, use the following code:
string contents = File.ReadAllText(path);
contents = contents.TrimStart('\n').Replace("\n", "\r\n");
File.WriteAllText(pathFixed, contents);
The fixed message can be loaded both by Rebex Secure Mail and third-party applications.