Uses 557K of libraries. Click here for Pure Java version (15280L/108K).
!7 sclass SentGMails 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 = theFolder(); 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; pcall { ret actualCalc(); } null; } L<Map> actualCalc() ctex { temp enter(); long startTime = sysNow(); Folder inbox = theFolder(); temp tempMailStore(inbox); new L<Map> l; inbox.open(Folder.READ_ONLY); int count = inbox.getMessageCount(); int n = max(1, count-numMsgs+1); Message[] messages = inbox.getMessages(n, count); print("Fetching " + n2(messages, "message")); inbox.fetch(messages, javaMail_fullFetchProfile()); int i = 1; for (Message _msg : reversed(messages)) { new LinkedHashMap map; //print("Loading message " + i++); IMAPMessage msg = cast _msg; map.put("To", InternetAddress.toString(msg.getRecipients(Message.RecipientType.TO))); 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); } Folder theFolder() { ret googleCode_gmail_folder("[Google Mail]/Sent Mail"); } }
Began life as a copy of #1016632
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: | #1016634 |
Snippet name: | Sent GMails [Dyn Module] |
Eternal ID of this version: | #1016634/9 |
Text MD5: | ee7d138a70741332bb6257fa0bc611b9 |
Transpilation MD5: | e1e549e3b60efef2e80fa280c4cedc2e |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-06 14:45:41 |
Source code size: | 3201 bytes / 95 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 445 / 977 |
Version history: | 8 change(s) |
Referenced in: | -