TomDuncan Active Member Licensed User Longtime User Oct 12, 2015 #1 Hi All, Is their an easy to to encode or decode Quoted printable data. This is the body of an email. Also with this body the body itself is being truncated. This is how it ends .. Code: Copy </blockquote><blockquote type=3D"cite"><di where this is what came in.. Code: Copy <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>Check it out<br><br>Tom Duncan<div>Sen= t from my iPad</div></div><div><br>Begin forwarded message:<br><br></div><bl= ockquote type=3D"cite"><div><b>From:</b> "Google+" <<a href=3D"mailto:nor= [email protected]">[email protected]</a>><br><= b>Date:</b> 15 September 2015 at 9:32:48 PM AEST<br><b>To:</b> <a href=3D"ma= ilto:[email protected]">[email protected]</a><br><b>Subject:</b> <b>= Top Google+ Pages suggested for you</b><br><b>Reply-To:</b> "Google+" <<a= href=3D"mailto:[email protected]">[email protected]= le.com</a>><br><br></div></blockquote><blockquote type=3D"cite"><div><!--= X-Notifications: 1:2cc647e12f000000 --><div style=3D"padding:10px 0;"><tabl= e style=3D"width:100%" cellpadding=3D"0" cellspacing=3D"0"><tbody><tr><td><a= href=3D"https://plus.google.com/_/notifications/emlink?emr=3D01313702348586= 381093&emid=3DCIDG_tT4-McCFdOYjAodtJMN9g&path=3D%2Fstream&dt=3D1= part of it anyway.. Tom Last edited: Oct 12, 2015
Hi All, Is their an easy to to encode or decode Quoted printable data. This is the body of an email. Also with this body the body itself is being truncated. This is how it ends .. Code: Copy </blockquote><blockquote type=3D"cite"><di where this is what came in.. Code: Copy <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>Check it out<br><br>Tom Duncan<div>Sen= t from my iPad</div></div><div><br>Begin forwarded message:<br><br></div><bl= ockquote type=3D"cite"><div><b>From:</b> "Google+" <<a href=3D"mailto:nor= [email protected]">[email protected]</a>><br><= b>Date:</b> 15 September 2015 at 9:32:48 PM AEST<br><b>To:</b> <a href=3D"ma= ilto:[email protected]">[email protected]</a><br><b>Subject:</b> <b>= Top Google+ Pages suggested for you</b><br><b>Reply-To:</b> "Google+" <<a= href=3D"mailto:[email protected]">[email protected]= le.com</a>><br><br></div></blockquote><blockquote type=3D"cite"><div><!--= X-Notifications: 1:2cc647e12f000000 --><div style=3D"padding:10px 0;"><tabl= e style=3D"width:100%" cellpadding=3D"0" cellspacing=3D"0"><tbody><tr><td><a= href=3D"https://plus.google.com/_/notifications/emlink?emr=3D01313702348586= 381093&emid=3DCIDG_tT4-McCFdOYjAodtJMN9g&path=3D%2Fstream&dt=3D1= part of it anyway.. Tom
Daestrum Expert Licensed User Longtime User Oct 12, 2015 #2 Did you just want it in clean html code ? <body> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <div> Check it out <br> <br>Tom Duncan <div> Sent from my iPad </div> </div> <div> <br>Begin forwarded message: <br> <br> </div> <blockquote type="cite"> <div> <b>From:</b> "Google+" <a href="mailto:[email protected]">[email protected]</a> <br> <b>Date:</b> 15 September 2015 at 9:32:48 PM AEST <br> <b>To:</b> <a href="mailto:***********@gmail.com">***********@gmail.com</a> <br> <b>Subject:</b> <b>Top Google+ Pages suggested for you</b> <br> Click to expand... Last edited: Oct 12, 2015 Upvote 0
Did you just want it in clean html code ? <body> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <div> Check it out <br> <br>Tom Duncan <div> Sent from my iPad </div> </div> <div> <br>Begin forwarded message: <br> <br> </div> <blockquote type="cite"> <div> <b>From:</b> "Google+" <a href="mailto:[email protected]">[email protected]</a> <br> <b>Date:</b> 15 September 2015 at 9:32:48 PM AEST <br> <b>To:</b> <a href="mailto:***********@gmail.com">***********@gmail.com</a> <br> <b>Subject:</b> <b>Top Google+ Pages suggested for you</b> <br> Click to expand...
TomDuncan Active Member Licensed User Longtime User Oct 12, 2015 #3 Yes, exactly. To Display an email in html format. It does have funny "=" and 3D bits as well. However, I think their is an error in the mail parse routine which is chopping off the tail of the body. Might have to ask another question for that. It is used in the pop email handling. Tom Upvote 0
Yes, exactly. To Display an email in html format. It does have funny "=" and 3D bits as well. However, I think their is an error in the mail parse routine which is chopping off the tail of the body. Might have to ask another question for that. It is used in the pop email handling. Tom
Daestrum Expert Licensed User Longtime User Oct 12, 2015 #4 To clean up the data I just used Code: Copy Dim outstring As String = "" outstring = s.Replace("="&Chr(10),"").Replace("=3D","=") outstring = outstring.Replace("<","").Replace(">","").Replace("&","&") outstring = outstring.Replace("%2F","/").Replace("ahref","a href") Where s is the input string. I then used 'jSoup' (from jsoup.org) to parse it into a readable format. (it can also search the document for elements) Code: Copy #if java import org.jsoup.Jsoup; import org.jsoup.helper.Validate; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public static String decode(String s){ Document doc = Jsoup.parseBodyFragment(s); Element body = doc.body(); return body.toString(); } #end if Last edited: Oct 12, 2015 Upvote 0
To clean up the data I just used Code: Copy Dim outstring As String = "" outstring = s.Replace("="&Chr(10),"").Replace("=3D","=") outstring = outstring.Replace("<","").Replace(">","").Replace("&","&") outstring = outstring.Replace("%2F","/").Replace("ahref","a href") Where s is the input string. I then used 'jSoup' (from jsoup.org) to parse it into a readable format. (it can also search the document for elements) Code: Copy #if java import org.jsoup.Jsoup; import org.jsoup.helper.Validate; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public static String decode(String s){ Document doc = Jsoup.parseBodyFragment(s); Element body = doc.body(); return body.toString(); } #end if
TomDuncan Active Member Licensed User Longtime User Oct 12, 2015 #5 That looks nice and easy, thanks will test in the morning. The code came from the b4j mail program. It was an e-mail that came to me and looked difficult to parse. So with jsoup if I used the entire email and used that to grab the body? Tom Upvote 0
That looks nice and easy, thanks will test in the morning. The code came from the b4j mail program. It was an e-mail that came to me and looked difficult to parse. So with jsoup if I used the entire email and used that to grab the body? Tom
Daestrum Expert Licensed User Longtime User Oct 12, 2015 #6 Yes, or you can specify which parts you want. eg, Code: Copy // in java code Element block = doc.select("blockquote[type=cite]).first(); return block.toString(); Will return the first blockquote with a type equal to 'cite' The truncation could be caused by the buffer being too small if that's how it reads the data from the pop3 server. Upvote 0
Yes, or you can specify which parts you want. eg, Code: Copy // in java code Element block = doc.select("blockquote[type=cite]).first(); return block.toString(); Will return the first blockquote with a type equal to 'cite' The truncation could be caused by the buffer being too small if that's how it reads the data from the pop3 server.
TomDuncan Active Member Licensed User Longtime User Oct 12, 2015 #7 Will check that as well, thanks. Upvote 0