0 votes
by (150 points)

Hello,

I use commercial version of Rebex Secure Mail .NET component for converting EML and MSG files to MHT format. After this, I use Microsoft Word public API to convert MHT file created by Rebex to PDF.

I have several issues I'd like to be fixed. The source EML files are available on (Microsoft Outlook 2010 is able to open all these EML files correctly!):
http://download.print-driver.com/files_exchange/mb/Rebex-EML-Component.rar

1) Rebex throws an exception when I try load 1-st file from this archive. My VB.NET source code is:

Dim msg As New MailMessage
msg.Load(sSrcFile)

2) Rebex is able to load 3 another EML files I sent you and even convert them to MHT. But, Microsoft Word 2010 is unable to open these MHT files. VB.NET code I use to convert EML to MHT is here:

Function MSG2MHT(ByVal mail As MailMessage, sOutMHT As String) As Boolean

        If mail.IsSigned Then
            mail.RemoveSignature()
        End If

        If mail.IsEncrypted Then
            If Not mail.CanDecrypt() Then
                ErrorMsgToLog("MSG2MHT - Unable to decrypt e-mail message.")
                Return False
            End If

            mail.Decrypt()
        End If

        While mail.Attachments.Count > 0
            mail.Attachments.RemoveAt(0)
        End While

        If Not mail.HasBodyHtml Then
            If mail.HasBodyText Then
                mail.BodyHtml = "<pre>" + HttpUtility.HtmlEncode(mail.BodyText) + "</pre>"
            End If
        End If


        Dim i As Integer = 0
        Do
            If i > mail.AlternateViews.Count - 1 Then
                Exit Do
            End If

            If mail.AlternateViews.Item(i).ContentType.MediaType = MediaTypeNames.Text.Html Then
                i += 1
                Continue Do
            End If

            mail.AlternateViews.RemoveAt(i)
        Loop

        mail.Save(sOutMHT)
        Return True
    End Function

Please let how to avoid issues I have. Or give me an idea when you will send me fixed version of Rebex Secure Mail .NET component!

Applies to: Rebex Secure Mail

1 Answer

+1 vote
by (73.5k points)

Hello Mikhael,

  1. Exception:
    This is a bug in the component, however it is already fixed. I have sent you a link to HOTFIX version to your email.

  2. MHT generation:
    With the given function I was able to generate MHT files for all mentioned files, however only "2 - eml to mht - Word load failed.mht" displays a content in Internet Explorer. Other files are shown as empty page, which is probably desired behavior.

If I try to open the MHT files in MS Word, 3 and 4 reports an error “… is not a valid Single File Web Page.”

It is caused due to the .mht file doesn’t contain HTML body. You can fix this by adding following code to the end of MSG2MHT method:

If mail.AlternateViews.Count = 0 Then
mail.BodyHtml = " "
End If

by (150 points)
Thank you, Lukas!
...