Android Question HTML emal body shows poorly in WebView

William Hunter

Active Member
Licensed User
Longtime User
I am loading an email msg body into a WebView as HTML. Some messages display correctly while others do not. They are all either HTMLor XHTML.

I have attached three image files for a message that does not show correctly. The first is how the message displays in the WebView. The second shows the first few lines of HTML code for the page. The third shows how the message displays in my email client. I don’t have a great understanding of HTML, XML and XHTML. Would someone please take a look at these images and tell me whether this is a case of a limitation in WebView, or otherwise? I don’t think it could be bad HTML, otherwise my email client would have a problem with it as well. Any help greatly appreciated.
MsgBody1_WebView.png MsgBody2_HTML_Code.png MsgBody3_EmailClient.png

Best regards :)
 

William Hunter

Active Member
Licensed User
Longtime User
I can't check much when you upload 0 byte files ;)
Hello sorex. I'll try to be clearer. I know both text files are 0 byte files. They are both for the same piece of email on the server. BodyRogers.txt was downloaded using the stripping Sub in my app. BodyRogers3.txt was downloaded by my app without the stripping Sub in play. Although I originally thought the stripping Sub had stripped it to a 0 byte file, instead it came through the Mailparser as a 0 byte file. Yet this mail displays OK in Thunderbird. So, it must be other than a 0 byte file on the server. My point was that I must not be using the Mailparser correctly, and is likely why I am getting these wierd characters in the first place. Oh the Joy! :eek: I'm wondering if my call to Mailparser must be in a different form, but can't find a likely explanation on the forum.

Best regards :)
 
Last edited:
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
Hello sorex. This is a little further info. Out of 14 messages on the server this AM, 13 displayed well while 1 did not when downloaded by my app using the strip sub. I am attaching image and text files for this message, as downloaded by my app, both stripped and not stripped. This is all a little difficult to make sense of.

Best regards :)
BodyTalbotsStrip.png BodyTalbotsNoStrip.png
 

Attachments

  • BodyTalbotsStrip.txt
    1 KB · Views: 190
  • BodyTalbotsNoStrip.txt
    1.1 KB · Views: 204
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
you need to replace =0A with nothing there BUT the html is incomplete that's why you don't see anything
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
you need to replace =0A with nothing there BUT the html is incomplete that's why you don't see anything
Hello sorex. You see the HTML as being incomplete as downloaded by my app. Yet the message displays correctly in Thunderbird (Image attached). This is why I now think that the problem occurs in Mailparser. I must not be using it correctly, but I see no other way on the forum.

Best regards :)
TalbotsThunderbird.png
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
Thank you sorex. I forwarded that Talbot message to myself, so that I could download it again with my app using the sub you have pointed me to. The message displayed correctly with only one minor difference. See the A in the upper left. This may be due to the fact it's a forwarded message. I will try this again when I receive more messages on the server. You have very likely resolved my problem. I will post the result latter.

Best regards
Screenshot_20160804-105114.png
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
that looks like an UTF8 identifier that's was added during the forward.
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
Hello Sorex. I downloaded another 0 byte message with my app. I took a look using Top to see what kind of message it was. It doesn't look like HTML to me. Do you recognize this format? I have attached an image file showing a few Top lines.

Best regards :)
BanksInsiderTop30.png
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
yes, that's multipart mime.

you need to grab the right part OR filter out the html part (the <html </html> portion)
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
yes, that's multipart mime.

you need to grab the right part OR filter out the html part (the <html </html> portion)
Hello sorex. I have hit a brick wall on this. I have been struggling trying to deal with multipart/alternative format. As I understand it, after a forum search, the Mailparser doesn’t support this format.

In order to suit my purpose the Mailparser would need modifications beyond my limited skills. I never was able to achieve satisfactory results, and therefore have no code solution to post. :(

How would one go about grabbing the right part OR filter out the html part (the <html </html> portion) from multipart mime? This would be helpful for me to know.

Best regards :)
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
with regex or substring
Thank you sorex. Those four little words make it sound so simple. Substring is not useful as incoming email is not static, and Substring requires indexing. As for Regular Expressions, I have not found an example of how this might be used to extract HTML for display. If anyone has successfully displayed multipart mime in a WebView, their help would be greatly appreciated.

Content-Transfer-Encoding formats are: Quoted-printable, Base64, 8-bit, 7-bit and Binary. I have found Erel's Quote-prinable example. Is there anything in any of these other formats that would help me? I'm rather lost on this and I really need code examples to help me progress. Thank you for your replies sorex, but I am not at the level where I find simple, all that you find simple.

Best regards :)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
copy an example inhere as code so that I can see how the parts look.

it's just text so I don't see why it won't work with substr or regex.
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
copy an example inhere as code so that I can see how the parts look.

it's just text so I don't see why it won't work with substr or regex.
Hello sorex. I seem to be making some headway. Out of 22 emails on the server today, 20 of them were properly displayed. I have spent a fair bit of time comparing the Top 30 to what comes through the Mailparser, and has been saved to a text file using the Davlik Debug Monitor. Below are some of my findings:

1. An item with encoding base64 comes through the Mailparser as a 0 byte file. This is likely a limitation of the Mailparser and something that I cannot rectify.

2. An item with encoding quoted-printable shown in the Top 30, comes through the Mailparser with a number of top lines up to “<!DOCTYPE HTML PUBLIC” missing. This will not display. See the attachments labeled Talbots.

3. An item that shows as Multipart-Mime in the Top 30, comes through the Mailparser with a number of top lines up to “<html><head>” missing. This piece of mail still displays OK. See attachments labeled TechRepublic.

I don’t know if any of these deficiencies can be corrected, and would appreciate your thoughts.

Best regards :)
BodyTabotsTop.png BodyTalbots.png BodyTechRepublicTop.png BodyTechRepublic.png
 

Attachments

  • RawBodyTalbots.txt
    1.1 KB · Views: 182
  • RawBodyTechRepublic.txt
    13.6 KB · Views: 235
Upvote 0

sorex

Expert
Licensed User
Longtime User
the talbot one is interrupted and doesn't contain much besides headers & styles and a hidden image, the rest is gone.
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
the talbot one is interrupted and doesn't contain much besides headers & styles and a hidden image, the rest is gone.
Hello sorex. The Talbot one is strange because that is what was downloaded from the server, processed by the Mailparser, and not modified in any way. What do you think about the item with encoding base64? Is this encoding that cannot be processed by the Mailparser? Also, is there an answer to why some of the leading text in two of these emails has been deleted in processing by the Mailparser? I think that these are difficiences in the Mailparser, but can't say that for certain, because I don't have the knowledge. I would like to have Erel's thoughts on this, as well as your own. Perhaps I'll get lucky, and catch you both in a good mood. ;)

Best regards :cool:
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
dunno, as written before I never use that mail parser.
Thank you sorex, I appreciate your help. I will start another thread and see if i can sort things out.

Best regards :)
 
Upvote 0
Top