Uses 557K of libraries. Click here for Pure Java version (15245L/108K).
!7 sclass LatestGMails extends DynTable { int numMsgs = 50; L<Map> data; void start { ownTimer(doEvery(10.0, 60.0, r actualUpdate)); } void actualUpdate { actualCalc(); updateMe(); } JComponent visualize() { JComponent c = super.visualize(); tablePopupMenuItemsThreaded(table, "Mail source code", r { long uid = parseLong((S) selectedTableCell(table, "UID")); if (uid == 0) ret; Folder inbox = googleCode_gmail_inbox(); temp tempMailStore(inbox); inbox.open(Folder.READ_ONLY); IMAPMessage msg = cast ((UIDFolder) inbox).getMessageByUID(uid); O content = msg.getContent(); if (isString(content)) showText("Mail " + uid, content); else if (content instanceof Multipart) { Multipart mp = cast content; int n = mp.getCount(); new L<S> l; for i to n: { Part part = mp.getBodyPart(i); S type = part.getContentType(); O partContent = part.getContent(); l.add(type + " / " + className(partContent)); if (partContent instanceof S) l.add(str(partContent)); } showText("Mail " + uid, joinWithEmptyLines(l)); } else print("Unknown content type: " + className(content)); }); ret c; } L<Map> calc() { temp enter(); if (data != null) ret data; ret actualCalc(); } L<Map> actualCalc() ctex { temp enter(); long startTime = sysNow(); Folder inbox = googleCode_gmail_inbox(); temp tempMailStore(inbox); new L<Map> l; inbox.open(Folder.READ_ONLY); int count = inbox.getMessageCount(); int n = max(1, count-numMsgs+1); for (int i = count; i >= n; i--) { new LinkedHashMap map; print("\nLoading message " + i + "\n"); IMAPMessage msg = cast inbox.getMessage(i); map.put("From", InternetAddress.toString(msg.getFrom())); map.put("Subject", msg.getSubject()); //map.put("Message number: " + msg.getMessageNumber()); map.put("Sent/Received", msg.getSentDate() + "/" + msg.getReceivedDate()); //O content = msg.getContent(); //print(" Content type: " + getClassName(content)); map.put("Size", toK(msg.getSize()) + " K"); map.put("[hidden] ID", msg.getMessageID()); pcall { map.put("UID", ((UIDFolder) inbox).getUID(msg)); } //map.put("Content Type", className(content) + " / " + msg.getContentType()); map.put("Content Type", msg.getContentType()); //print(" Content type: " + msg.getContentType()); l.add(map); } //inbox.close(false); //inbox.getStore().close(); print("Fetching " + n2(l, " latest GMail") + " took: " + elapsedTime(startTime) + " ms"); ret setFieldAndReturn(data := l); } }
Began life as a copy of #1016066
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016630 |
Snippet name: | Latest GMails v2 [Dyn Module] |
Eternal ID of this version: | #1016630/4 |
Text MD5: | 361f0c80d46002b0d796032ac40e3d53 |
Transpilation MD5: | 884875adcfab5571237e1267aabc7fe3 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-25 23:01:34 |
Source code size: | 2896 bytes / 82 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 363 / 792 |
Version history: | 3 change(s) |
Referenced in: | #1016632 - Latest GMails v3 [Dyn Module] |