TextBody.TextData quoted printable

Jun 2, 2013 at 12:05 PM
Hi all,
I have an email which contains this text:

Viele Grüße

In the TextBody.TextData i get the text as following:

Viele Gr=FC=DFe

Are there any possibility to decode this text easily ?

I have found out that this is about quoted printable.

Thanks.
Coordinator
Jun 2, 2013 at 6:36 PM
Hi mzda,

at the moment the TextBody and HtmlBody won't be decoded automatically, but you can use the GetDecodedBody method of the Message to get a decoded version. A short sample is provided in the documentation: https://imapx.codeplex.com/documentation

I'd also like to inform you that this method won't be available in future releases, being replaced by automated body decoding.

Greets,

Pavel Azanov
Jun 2, 2013 at 7:06 PM
Hi Pavel,
thanks for the fast response to my issue.

I have already tried that solution too.

I am using a GMail account with the IMAP Access.

Following is my code:

bool isHtml = true;
string body = mm.GetDecodedBody(out isHtml);

The email I am trying to get is an HTML one. And I always get the HTML Email for my code above and for this following code also:

bool isHtml = false;
string body = mm.GetDecodedBody(out isHtml);


Thanks.

Best Regards,
Donny
Jun 2, 2013 at 7:48 PM
Hi Pazel,
I have found another simple workaround, which works for me at least:
    private string getPlainTextFromHtml(string htmlString)
    {
        string htmlTagPattern = "<.*?>";
        string brPattern = "<br[\\s]*\\/*>";
        var regexCss = new Regex("(\\<script(.+?)\\</script\\>)|(\\<style(.+?)\\</style\\>)", RegexOptions.Singleline | RegexOptions.IgnoreCase);
        htmlString = regexCss.Replace(htmlString, string.Empty);
        htmlString = Regex.Replace(htmlString, brPattern, "\n");
        htmlString = Regex.Replace(htmlString, htmlTagPattern, string.Empty);
        htmlString = Regex.Replace(htmlString, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
        htmlString = htmlString.Replace("&nbsp;", string.Empty);

        return htmlString;
    }
Best Regards,
Donny
Coordinator
Jun 2, 2013 at 9:19 PM
Edited Jun 2, 2013 at 9:24 PM
Hi Donny,

currently the GetDecodedBody method always returns the HTML body if there is one, so the parameter isHtml is actually just to let you know if the returned body is the HtmlBody and has no effect if setting it to true or false.

I'll provide a small fix tomorrow morning, so you can return both text or html by specifying the isHtml argument.


Best regards,

Pavel Azanov