The code from this post:
https://www.b4x.com/android/forum/threads/using-pop3-and-mailparser.66978/#post-424205 properly parses the encoded string. However you need to first extract the encoded string from the header.
You can see how I did it in the second post. You just need to replace the B with Q.
Thank you Erel. I have tried using your modified (B to Q) code in the second post as below:
Sub ParseQuotePrintableHeader(h As String) As String
Dim sb As StringBuilder
sb.Initialize
Dim su As StringUtils
Dim m As Matcher = Regex.Matcher("=\?([^?]+)\?Q\?([^?]+)\?=", h)
Dim lastIndex As Int = 0
Do While m.Find
If m.GetStart(0) > lastIndex Then
sb.Append(h.SubString2(lastIndex, m.GetStart(0)))
End If
Dim b() As Byte = su.DecodeBase64(m.Group(2)) ' Not for quoted-printable
sb.Append(BytesToString(b, 0, b.Length, m.Group(1)))
lastIndex = m.GetEnd(0)
Loop
sb.Append(h.SubString(lastIndex))
Return sb.ToString
End Sub
It returned the following logged results:
Unparsed Q-P Subject Header: =?UTF-8?Q?3=20special=20offers=3A=20=246=2E99=20Mozzarella=20Sticks=20and=20=2410=2E99=20Italian=20Style=20Beef=20Meatballs=2C=20plus=20BONUS=20offer?=
Parsed Q-P Subject Header: ���
Unparsed Q-P From Header: "=?UTF-8?Q?M=26M=20Food=20Market?=" <emax@emails.mmfoodmarket.com>
Parsed Q-P From Header: "?�?���mj�" <emax@emails.mmfoodmarket.com>
My email client displays the headers as below:
3 special offers: $6.99 Mozzarella Sticks and $10.99 Italian Style Beef Meatballs, plus BONUS offer
emax@emails.mmfoodmarket.com
While I seem to have hit an impasse here, I've gained a whole new respect for those who develop email clients. Incidentally, the sub posted in post #8 of this web link:
https://www.b4x.com/android/forum/t...nicate-with-android-devices.11310/#post-87366 works very well, while the sub posted in the following web link does not. post:
https://www.b4x.com/android/forum/threads/using-pop3-and-mailparser.66978/#post-424205 This last comment does not refer to the parsing of headers, rather the message body.
Regards
EDIT: I tried earlier to attach the raw unprocessed message, but Chrome's auditing blocked me. I have now uploaded it using Firefox.
This was the error message:
This page isn’t working
Chrome detected unusual code on this page and blocked it to protect your personal information (for example, passwords, phone numbers, and credit cards).
Try visiting the site's homepage.
ERR_BLOCKED_BY_XSS_AUDITOR