!7 sclass LatestGMails extends DynTable { int numMsgs = 50; L data; void start { ownTimer(doEvery(60.0, r actualUpdate)); } void actualUpdate { actualCalc(); } L calc() { temp enter(); if (data != null) ret data; ret actualCalc(); } L actualCalc() ctex { temp enter(); long startTime = sysNow(); Folder inbox = gmail_inbox(); new L 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()); map.put("Content Type", msg.getContentType()); //print(" Content type: " + className(content) + " / " + 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); } }