jstedfast / MailKit

A cross-platform .NET library for IMAP, POP3, and SMTP.

Home Page:http://www.mimekit.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not load the file 'I18N.CJK'.

fredericoregateiro opened this issue · comments

Describe the bug
In a xamarin project

Platform (please complete the following information):

  • OS: Android
  • .NET Runtime: Mono
  • .NET Framework: netstandard2.1
  • MailKit Version: 410
  • Xamarin.Forms: 5.0.0.2578

Exception
Could not load the file 'I18N.CJK'.

image

To Reproduce
Steps to reproduce the behavior:
Create a MimeMessage object

using var message = new MimeMessage();

Expected behavior
Create a MimeMessage object

Code Snippets

using var message = new MimeMessage();

Protocol Logs
Tested on emulator width android 10 and a real phone with android 8 and i don't know how to get the logs

After some searching i added the CJK encoding from the properties in the xamarin.android project and now i get this error:
No data is available for encoding 51936. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

Call System.Text.Encoding.RegisterProvider (System.Text.CodePagesEncodingProvider.Instance); at program startup.

I would like to leave here some comments my experience in integrating this library in a xamarin project.

  • check the MailkitLite, the diference in size on my apk is almost 5MB. Here it could have some reference in the documentation, i didn't find any

  • always check the encodings in all configurations (debug and release)
    image

  • whe creating a mime message using var message = new MimeMessage(); i get this exceptions:
    System.NotSupportedException: 'No data is available for encoding 51936. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.'
    and
    System.NotSupportedException: 'No data is available for encoding 52936. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.'
    just continue and the email gets delivered.

FWIW, Xamarin.iOS and Xamarin.Android are not going to be supported much longer by Microsoft (they have about another year of support).

They are recommending that everyone upgrade to Microsoft.iOS and Microsoft.Android which are the .NET 6.0/7.0/8.0 versions (and are the core of the MAUI platform).

Once you make that switch, you'll need to include the System.Text.Encoding.CodePages nuget and then in your program initialization, call:

System.Text.Encoding.RegisterProvider (System.Text.CodePagesEncodingProvider.Instance);

MimeKitLite is a stripped-down version of MimeKit that eliminates almost everything from the MimeKit.Cryptography namespace. That's the only difference.

IOW, MimeKitLite loses S/MIME, PGP, and DKIM/ARC support.

Most people don't really need that stuff, so it's fine to go with MimeKitLite.