Uses 666K of libraries. Click here for Pure Java version (1052L/8K/28K).
!7 lib 1003225 // JavaMail lib 1400081 // activation import javax.mail.*; import javax.mail.PasswordAuthentication; import javax.mail.internet.*; p { final S username = "stefan.reich.maker.of.eye@gmail.com"; final S password = findGMailPassword(username); new Properties props; props.setProperty("mail.store.protocol", "imaps"); Session session = Session.getInstance(props, null); Store store = session.getStore(); store.connect("imap.gmail.com", username, password); /*Folder[] folderList1 = store.getPersonalNamespaces(); for (Folder f : folderList1) print(">> [" + f.getFullName() + "]");*/ // This fails: (folder not found) // Folder[] folderList = store.getFolder("[Gmail]").list(); listFolders(store.getDefaultFolder(), ""); Folder inbox = store.getFolder("[Google Mail]/Sent Mail"); inbox.open(Folder.READ_ONLY); int idx = inbox.getMessageCount(); print("Loading message " + idx); Message msg = inbox.getMessage(idx); Address[] in = msg.getFrom(); for (Address address : in) print("FROM:" + address.toString()); print("Content type: " + getClassName(msg.getContent())); //BodyPart bp = mp.getBodyPart(0); System.out.println("To: "+InternetAddress.toString(msg.getRecipients(Message.RecipientType.TO))); System.out.println("Cc: "+InternetAddress.toString(msg.getRecipients(Message.RecipientType.CC))); System.out.println("Bcc: "+InternetAddress.toString(msg.getRecipients(Message.RecipientType.BCC))); System.out.println("SENT DATE:" + msg.getSentDate()); System.out.println("SUBJECT:" + msg.getSubject()); //System.out.println("CONTENT:" + bp.getContent()); } svoid listFolders(Folder folder, S prefix) ctex { Folder[] folderList = folder.list(); for (int i = 0; i < folderList.length; i++) { print(prefix + folderList[i].getFullName()); listFolders(folderList[i], prefix + " "); } }
Began life as a copy of #1003227
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003300 |
Snippet name: | Print last sent mail on GMail and list folders [Spike] |
Eternal ID of this version: | #1003300/3 |
Text MD5: | d4a0adf3601f303e34b94d34fd74fe25 |
Transpilation MD5: | 146981ae8939acb037078cf263a11e93 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-26 00:27:17 |
Source code size: | 1946 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 838 / 839 |
Version history: | 2 change(s) |
Referenced in: | [show references] |