1 | lib 1002510 // jsoup |
2 | |
3 | static S mail_getText(Message message) ctex { |
4 | fixContextClassLoader(); |
5 | S result = ""; |
6 | if (message.isMimeType("text/plain")) { |
7 | result = message.getContent().toString(); |
8 | } else if (message.isMimeType("multipart/*")) { |
9 | MimeMultipart mimeMultipart = (MimeMultipart) message.getContent(); |
10 | result = mail_getText_fromMimeMultipart(mimeMultipart); |
11 | } |
12 | ret result; |
13 | } |
14 | |
15 | static S mail_getText_fromMimeMultipart(MimeMultipart mimeMultipart) ctex { |
16 | S result = ""; |
17 | int count = mimeMultipart.getCount(); |
18 | for (int i = 0; i < count; i++) { |
19 | BodyPart bodyPart = mimeMultipart.getBodyPart(i); |
20 | if (bodyPart.isMimeType("text/plain")) { |
21 | result = result + "\n" + bodyPart.getContent(); |
22 | break; // without break same text appears twice in my tests |
23 | } else if (bodyPart.isMimeType("text/html")) { |
24 | String html = (String) bodyPart.getContent(); |
25 | result = result + "\n[from HTML]\n" + org.jsoup.Jsoup.parse(html).text(); |
26 | } else if (bodyPart.getContent() instanceof MimeMultipart){ |
27 | result = result + mail_getText_fromMimeMultipart((MimeMultipart)bodyPart.getContent()); |
28 | } |
29 | } |
30 | ret result; |
31 | } |
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: | 463 / 488 |
Version history: | 4 change(s) |
Referenced in: | [show references] |