Error of System.TypeInitializationException: 'The type initializer for '#=zCMIThOB2qmvZFW_Ifh4QKFf70WB9CEe4Rw==' threw an exception while using Aspose.Email version 23.10

Hi, I am using Aspose.Email for Outlook reminder and it throwing below error

System.TypeInitializationException: 'The type initializer for ‘#=zCMIThOB2qmvZFW_Ifh4QKFf70WB9CEe4Rw==’ threw an exception
Inner Exception
NotSupportedException: No data is available for encoding 860. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

My Code is:
body.Clear();
List data = new List();
data = list.Select(x => x).Where(x => x.ContactDate == item).ToList();
DateTime RemindDate = DateTime.UtcNow;

            body.Append("<html><body>");
            foreach (var obj in data)
            {
                body.Append("<ul style='list-style-type: square;'>");
                body.Append("<li>Client Name : " + obj.ClientName + "");
                body.Append("<br>Candidate Name : " + obj.CandidateName + " (" + obj.RefNo + ") " + "");
                body.Append("<br>Check Name :" + obj.CheckName);
                body.Append("<br>Contact Date : " + obj.ContactDate + "");
                body.Append("<br>Reason : " + obj.Reason + "");
                body.Append("</li><br />");
                body.Append("</ul>");
            }

            body.Append("</body></html>");
            
            Aspose.Email.License license = new Aspose.Email.License();
            license.SetLicense("Aspose.Total.lic");
            DateTime EndTime = DateTime.Parse(item).Date.Add(new TimeSpan(23, 59, 00)).ToUniversalTime();
            var contact_date = DateTime.Parse(item).Date;
            if (contact_date < DateTime.Now.Date)
            {
                RemindDate = DateTime.Parse(item);
            }
            var enc = CodePagesEncodingProvider.Instance.GetEncoding(1252);
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            Aspose.Email.Calendar.Appointment app = new Aspose.Email.Calendar.Appointment("HK", RemindDate.ToUniversalTime(), EndTime, "support@abc.com", supervisorEmail);
            app.Summary = "Future employment check reminder from [" + RemindDate.ToString("dd-MM-yyyy") + "] to [" + EndTime.ToString("dd-MM-yyyy") + "]";
            app.MethodType = AppointmentMethodType.Publish;
            Aspose.Email.MailMessage msg = new Aspose.Email.MailMessage("support@abc.com",supervisorEmail);

            msg.HtmlBody = body.ToString(); //Setting Email Body.
            msg.IsBodyHtml = true; //Setting Email Body type HTML.
            msg.PreferredTextEncoding = Encoding.GetEncoding(1252);

            Aspose.Email.AlternateView view = app.RequestApointment();
            msg.AddAlternateView(view);

            //msg.To = supervisorEmail;
            //msg.From = "support@abc.com";
            //var enc = CodePagesEncodingProvider.Instance.GetEncoding("UTF8");
            //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            //Stream str = new MemoryStream();
            //msg.Save(str);
            MapiConversionOptions conversionOptions = new MapiConversionOptions();
            conversionOptions.Format = OutlookMessageFormat.Unicode;
            conversionOptions.ForcedRtfBodyForAppointment = false;
            Aspose.Email.Mapi.MapiMessage mapi = Aspose.Email.Mapi.MapiMessage.FromMailMessage(msg,conversionOptions);//error throws here
            Aspose.Email.Mapi.MapiCalendar calendar = (Aspose.Email.Mapi.MapiCalendar)mapi.ToMapiMessageItem();
            calendar.ReminderSet = true;
            calendar.ReminderDelta = 1;

Can please help to solve the issue

Hello @mukesh.kr,

Could you please provide a saved eml file to reproduce the issue at our end?

Thank you.

Hi @margarita.samodurova Thanks for reply.

I have no saved eml file. I am creating html body at runtime and setting the reminder. With my earlier code in MVC application using aspose.email version 6.9 it was running, but not running When I added same in .netcore application. It was throwing error of unable to set license. Then I upgrade dll to version of 23.10 and license issue resolved with current license. But above error remain as I changed code according to new dll.

Can you please use same code as above and provide solution.

Thanks.

Hi @mukesh.kr ,

We are unable to reproduce the error.
It should be noted that the .NET Core version has a dependency on the following libraries:

  • System.Text.Encoding.CodePages (>= 5.0.0)
  • System.Security.Cryptography.Pkcs (>= 7.0.3).

Can you confirm that the above dependencies are added to your project?
P.S.: If you add Aspose.Email dll with NuGet, these dependencies are automatically added to the project.

Hi @margarita.samodurova ,

These 2 was not added in project. Now added but still getting same error.

image.png (3.4 KB)
image.png (71.0 KB)

@mukesh.kr ,

The problem is obviously with the environment settings. Please let us know which OS and Visual Studio versions you’re using.

Hi @margarita.samodurova Thanks for your help.

I removed above two nuget packages and also removed aspose.email dll from project.
Then added aspose.email from nuget package and it works. Oulook reminder set with body defined.

Hi @mukesh.kr ,

Thank you for using Aspose products.

If you have any other questions, please feel free to ask.