lib 1002510 // jsoup static S mail_getText(Message message) ctex { fixContextClassLoader(); S result = ""; if (message.isMimeType("text/plain")) { result = message.getContent().toString(); } else if (message.isMimeType("multipart/*")) { MimeMultipart mimeMultipart = (MimeMultipart) message.getContent(); result = mail_getText_fromMimeMultipart(mimeMultipart); } ret result; } static S mail_getText_fromMimeMultipart(MimeMultipart mimeMultipart) ctex { S result = ""; int count = mimeMultipart.getCount(); for (int i = 0; i < count; i++) { BodyPart bodyPart = mimeMultipart.getBodyPart(i); if (bodyPart.isMimeType("text/plain")) { result = result + "\n" + bodyPart.getContent(); break; // without break same text appears twice in my tests } else if (bodyPart.isMimeType("text/html")) { String html = (String) bodyPart.getContent(); result = result + "\n[from HTML]\n" + org.jsoup.Jsoup.parse(html).text(); } else if (bodyPart.getContent() instanceof MimeMultipart){ result = result + mail_getText_fromMimeMultipart((MimeMultipart)bodyPart.getContent()); } } ret result; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1012849 |
| Snippet name: | mail_getText - uses JSoup to extract from HTML messages |
| Eternal ID of this version: | #1012849/5 |
| Text MD5: | 941aa5201feead91b14d18c959c43041 |
| Author: | stefan |
| Category: | javax / mail |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-12-14 19:24:06 |
| Source code size: | 1199 bytes / 31 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 692 / 707 |
| Version history: | 4 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1030609 - JSoup [Include] |