How to make RTF mail look beter when parsed by Rebex?

+1 vote
asked Aug 6, 2013 by Jakub Bartkowiak (420 points)
edited Sep 29, 2014

Here is a sample email sent from MS Outlook in RTF format. I would like to use Rebex to parse this file and generate HTML in order to display this email on my website. The problem is the result when using Rebex is not quite what i expect. Am i doing something wrong or maybe this mail format is not supported? This is how the email looks like in Outlook:

alt text


and this is how it looks like when displaying html retrieved from Rebex after parsing this file:


alt text

Applies to: Rebex Secure Mail

3 Answers

0 votes
answered Aug 6, 2013 by Lukas Matyska (43,890 points)
edited Sep 2, 2013
 
Best answer

I have improved the RTF to HTML conversion to support RTF of your mail better. Please try this HOTFIX trial.

If you have bought our component already, please send your order details or your registered email to support@rebex.net and I will send you link to full version.

commented Aug 7, 2013 by Jakub Bartkowiak (420 points)
edited Sep 2, 2013

Thank you Lukas for your fast response and solution. It work as expected but i have two concerns:

  1. I had to download the mail once again from the server since it seems that RTF conversion is done when downloading/saving not when loading message from stream. I was expecting that reading my old mail files and passing them thru the hotfix version would result in valid HTML content.

  2. Embedded images are stored as Attachments collection. In other mail i saw embedded images stored as Resources. I saw a post that said i should stick to Resources collection but in this case I can't. I ended up doing this:

    message.Attachments
    .Cast<AttachmentBase>()
    .Concat(message.Resources)
    .Where(a => a.ContentId != null)
    

We are still evaluating Rebex library but we are pretty sure right now that this is it. We used Mailbee before but i like you level of support more :)

commented Aug 7, 2013 by Lukas Matyska (43,890 points)
edited Sep 2, 2013

To 1: it is probably because you saved an email with HTML created from RTF by old version.

When you reloaded the mail with the new version, the mail contains an HTML view already, so RTF to HTML conversion was not performed.

Then you downloaded the mail from your server, which doesn't contain an HTML view, so RTF to HTML conversion was performed using new version.

To 2: it is a bug. All images referred from HTML should be in the Resources collection. Please try the current HOTFIX trial.

Thank you for pointing to it.

+1 vote
answered Aug 8, 2013 by Jakub Bartkowiak (420 points)
edited Sep 2, 2013

To 1: Yes thats exactly what happened and i understand the result. My point is that maybe you could allow user to chose in what format to save the mail on disk. I would prefer to save the email in unchanged format so that the RTF to HTML conversion is performed on runtime. This way each time you make your RTF parser better all i need to do is update the libraries and run it against all saved emails. Right now i have to download the emails again from mail server where they can be already deleted. This is just an idea.

To 2: Yes the bug is fixed thanks! If you would like to make your parser even better here is another sample email in RTF format. Just to be clear, I'm not personaly using RTF but potential clients can so I'm trying to prepare for it. Email was created in Outlook 2013 and i added two images as attachments and two as embedded images. Below are two screenshots of how the email looks like in Outlook and when parsed to HTML using Rebex library. One difference is the missing footer image and the other thing is that images added as attachments are recognized are accessable after parsing in Resources collection (maybe it should be in Attachments ?) This is no deal breaker for me but if you strive for perfection I'm willing to provide sample data :)

alt text


And here how it looks like when parsed to HTML using Rebex library


alt text

commented Aug 8, 2013 by Tomas Knopp (58,890 points)
edited Sep 2, 2013

1) It is possible to save the original email with the help of GetMessage method (available for both Pop3 and Imap client objects). You can save the emails from server with no modification being done by Rebex like this:

        var client = new Pop3();
        client.Connect("server", SslMode.Explicit);
        client.Login("username", "password");

        // save the original eml "as is" to local disk.
        client.GetMessage(sequenceNumber, @"C:\myData\mail.eml");

        // later you can invoke the Rebex conversion by loading the original email into MailMessage object:
        MailMessage mail = new MailMessage();
        mail.Load(@"C:\myData\mail.eml");
        mail.Save(@"C:\myData\mail-converted.eml");

Hope this will solve your issue.

2) Thank you for the feedback we will look into the matter and let you know when a solution is ready.

commented Aug 8, 2013 by Jakub Bartkowiak (420 points)
edited Sep 2, 2013

@Tomas: thank you for the snippet, that's just what I needed. I'm using GetMessage with MemoryStream so that i can create MailMessage object from it, decide if i want to save the message and save it from the stream to disk. This way I will be able to provide mail html updates for all stored emails when your library gets any converter related updates. Great to hear that you will check the next problem i reported, i will be awaiting your response.

commented Aug 12, 2013 by Tomas Knopp (58,890 points)
edited Sep 2, 2013

Hello,

first of all, thank you for your valuable feedback!

I have prepared another hotfix which fixes the issue with missing footer link you reported above.

Regarding the issue with attached images not displayed in the same way as Outlook 2013 does.

Well, this is a tricky story, I will have to dig a bit deeper to make clear what is actually going on:

the key difference is that the email converted by Rebex is a MIME HTML email which is universally viewable by email clients.

So unlike Outlook 2013 which enables user to be able to click on 1 of the 'dexter.jpg' icons and consequently open the real attachment, we do not have means for implementing this behaviour 'into' the email. This said, from Rebex point of view it is not possible to 'make' the email clients create a working link to an attached image.

There are 3 options as to what we can do with similarly attached images from winmail.dat emails:

1) Show only the filename of the image and then maybe display the actual image below the normal mail body (e.g. divided by a line after the mail body).

2) Show only the filename of the image and then add the images into Attachments collection

3) Treat them the same way as embedded images - i.e. directly embed them into the mail body, and add the images into Resources collection.

We have chosen solution 3, if you like one of the other possible solutions more, please let us know.

commented Sep 2, 2013 by Jakub Bartkowiak (420 points)
edited Sep 2, 2013

I'm ok with solutions 2 and 3 so solution 3 it is ;)

+1 vote
answered Aug 20, 2013 by Lukas Matyska (43,890 points)
edited Aug 20, 2013

All features discussed in this thread (which were added into HOTFIX version recently) are now included in the public release 2013 R2 (build number 4981).

...