Set Encoding of MboxrdStorageReader for mbox?

Hello! We’ve been using .NET version 17.1.0.0 and recently upgraded to 21.5.0.

When reading an mbox messages that do specify a charset, e.g. Content-Type: text/html; charset=“UTF-8”, the message body encoding appears to default to UTF-8 in version 17.1.0.0.

var reader = new MboxrdStorageReader(stream, false);
var message = reader.ReadNextMessage();
// message.BodyEncoding = {Encoding} null
// message.PreferredTextEncoding = UTF8Encoding
// message.Body = 🥔

When reading the same mbox message in version 21.5.0, the message body encoding defaults to SBCSCodePageEncoding (iso-8859-1).

var reader = new MboxrdStorageReader(stream, false);
var message = reader.ReadNextMessage();
// message.BodyEncoding = SBCSCodePageEncoding
// message.PreferredTextEncoding = SBCSCodePageEncoding
// message.Body = 🥔

This causes the body to be different after upgrading versions. Is it possible to set the encoding for MboxrdStorageReader much like other readers can with LoadOptions.PrefferedTextEncoding? Can this be added as a feature for MboxrdStorageReaderOptions?

Thank you.

mbox.zip (387 Bytes)

@edomag,
Welcome to our community! Thank you for posting the query. I reproduced the problem on my side and found no option to specify the encoding for the reader. I logged the issue with ID EMAILNET-40326 in our tracking system. Our development team will consider such a possibility. I will inform you of any progress.

1 Like

@edomag,
With the upcoming release of Aspose.Email 21.7 (towards the end of July), you will be able to set preferred encoding for messages like this:

var options = new MboxLoadOptions { PreferredTextEncoding = Encoding.UTF8 };
var reader = new MboxrdStorageReader("sample.mbox", options);
var message = reader.ReadNextMessage();

Great! Thanks for such quick replies!

The issues you have found earlier (filed as EMAILNET-40326) have been fixed in this update.