We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Contact info (*.MSG) with wrong encoding after conversion

Hello support-team,

im trying to convert contact information in *.MSG file format to a pdf document. Special characters like öäüß got lost in this process.

​​

Aspose.Email.dll version 18.12
Aspose.Words.dll version 19.01

Example file: see https://1drv.ms/u/s!AtnjspWuoT5CiR_n5z7BwE6R2JZW
Result: see https://1drv.ms/u/s!AtnjspWuoT5CiSCohNNe_gnGz00T

Example Code:

    public static void TestContactInMsgContainter()
    {

        string sourceFN = @"c:\Subversion\ccDCS3\TestData\Source\Contact3.msg";
        string destFNMhtml = Path.ChangeExtension(sourceFN, "mht");
        string destFN = Path.ChangeExtension(sourceFN, "pdf");

        if (File.Exists(destFN)) File.Delete(destFN);
        if (File.Exists(destFNMhtml)) File.Delete(destFNMhtml);

        using (MapiMessage msg = MapiMessage.FromFile(sourceFN))
        {
            MailConversionOptions op = new MailConversionOptions();
            //op.PreserveEmbeddedMessageFormat = true;
            using (MailMessage eml = msg.ToMailMessage(op))
            {
                //Prepare the MHT format options
                MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
                mhtSaveOptions.CheckBodyContentEncoding = true;
                mhtSaveOptions.PreserveOriginalBoundaries = true;
                mhtSaveOptions.SaveAttachments = true;
                mhtSaveOptions.SkipInlineImages = false;
                MhtFormatOptions formatOp = MhtFormatOptions.WriteHeader | MhtFormatOptions.RenderVCardInfo | MhtFormatOptions.DisplayAsOutlook | MhtFormatOptions.WriteOutlineAttachments | MhtFormatOptions.NoEncodeCharacters;
                mhtSaveOptions.RenderedContactFields = ContactFieldsSet.NameInfo | ContactFieldsSet.PersonalInfo | ContactFieldsSet.Telephones | ContactFieldsSet.Events | ContactFieldsSet.ElectronicAddresses| ContactFieldsSet.PhysicalAddresses| ContactFieldsSet.ProfessionalInfo | ContactFieldsSet.OtherFields;
                mhtSaveOptions.MhtFormatOptions = formatOp;
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.FirstName] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.FirstName].Replace("First Name", "Vorname");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.LastName] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.LastName].Replace("Last Name", "Nachname");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.FullName] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.FullName].Replace("Full Name", "Name");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.MiddleName] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.MiddleName].Replace("Middle Name", "Namenszusatz");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Mobile] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Mobile].Replace("Mobile", "Mobil");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Birthday] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Birthday].Replace("Birthday", "Geburtstag");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Business] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Business].Replace("Business", "Arbeit");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.BusinessAddress] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.BusinessAddress].Replace("Business Address", "Adresse (Arbeit)");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.BusinessFax] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.BusinessFax].Replace("Business Fax", "Fax (Arbeit)");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.BusinessHomePage] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.BusinessHomePage].Replace("Business Home Page", "Homepage (Arbeit)");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Company] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Company].Replace("Company", "Firma");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Department] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Department].Replace("Department", "Abteilung");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Email] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Email].Replace("E-mail", "E-Mail");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Gender] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Gender].Replace("Gender", "Geschlecht");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Hobbies] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Hobbies].Replace("Hobbies", "Hobbys");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Home] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Home].Replace("Home", "Privat");
                mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.HomeAddress] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.HomeAddress].Replace("Home Address", "Adresse (Privat)");
            }
        }
        Aspose.Words.LoadOptions loadOpt = new Aspose.Words.LoadOptions()
        {
            LoadFormat = Aspose.Words.LoadFormat.Mhtml,
            // Encoding= System.Text.Encoding.UTF8
        };
        Aspose.Words.Document wordDoc = new Aspose.Words.Document(destFNMhtml, loadOpt);
        wordDoc.Save(destFN, Aspose.Words.SaveFormat.Pdf);
    }  

Best regards, Martin

bugid#25545

@m.pfeifer,

Thank you for contacting Aspose Support.

We were able to reproduce the issue that you reported and have logged a ticket in our issue tracking system as EMAILNET-39252 to investigate this scenario further. We will update you here as soon as additional information is available.

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