Autodetect codepage issue

We are having an issue with msg files that have PR_INTERNET_CPID set to 50949.

This throws an exception that 50949 is an invalid windows codepage:

MailMessage mailMessage= mapiMessage.ToMailMessage(new MailConversionOptions());

This codepage is Korean auto-detect. CODEPAGEID | Microsoft Learn

If we open the msg in outlook and use outlookspy to change PR_INTERNET_CPID to 51949 (EUC Korean)… it works.

We need to do this programmatically and I’m not having success.

After opening the mapiMessage we do the following:

        if (mapiMessage.Properties[MapiPropertyTag.PR_INTERNET_CPID].GetLong() == 50949)
        {
            // CP_KAUTODETECT - 50949 - Indicates Korean auto-detect (50949).
            // force this to 
            // 51949 - euc-kr - EUC Korean
            mapiMessage.Properties.Remove(MapiPropertyTag.PR_INTERNET_CPID);
            mapiMessage.SetProperty(new MapiProperty(MapiPropertyTag.PR_INTERNET_CPID, BitConverter.GetBytes(51949)));
        }

Which seems to execute fine… however this is still throwing the same invalid codepage “50949”.

MailMessage mailMessage= mapiMessage.ToMailMessage(new MailConversionOptions());

Can you tell us what we are doing wrong?

We are using aspose.email v16.10… however I updated to v17.11 and have the same issue.

@PeteLee,

Please share your sample file with us for further investigations at our end. Ideally, the API should not raise any exception with the file and should work properly.

dis-5033-for-aspose.msg.zip (5.2 KB)

see attached…

@PeteLee,

We have tested your sample message file and above code with the latest version of Aspose.Email for .NET 17.11 and it works fine at our end. Please try it with this latest version and let us know your feedback.

As I mentioned in the second reply of this thread… we tried v17.11 and have the same issue.

What version of .net runtime are you using?

Can you provide the sample code that you used to do this successfully?

@PeteLee,

We loaded the attached MSG file using MapiMessage and used exactly the same code you have shared in your first code. We are using .NET Framework 4.6 in our application with the latest version Aspose.Email for .NET 17.11 at our end.