Uses 666K of libraries. Click here for Pure Java version (1052L/8K/28K).
1 | !7 |
2 | |
3 | lib 1003225 // JavaMail |
4 | lib 1400081 // activation |
5 | |
6 | import javax.mail.*; |
7 | import javax.mail.PasswordAuthentication; |
8 | import javax.mail.internet.*; |
9 | |
10 | p {
|
11 | final S username = "stefan.reich.maker.of.eye@gmail.com"; |
12 | final S password = findGMailPassword(username); |
13 | |
14 | new Properties props; |
15 | props.setProperty("mail.store.protocol", "imaps");
|
16 | |
17 | Session session = Session.getInstance(props, null); |
18 | Store store = session.getStore(); |
19 | store.connect("imap.gmail.com", username, password);
|
20 | |
21 | /*Folder[] folderList1 = store.getPersonalNamespaces(); |
22 | for (Folder f : folderList1) |
23 | print(">> [" + f.getFullName() + "]");*/
|
24 | |
25 | // This fails: (folder not found) |
26 | // Folder[] folderList = store.getFolder("[Gmail]").list();
|
27 | |
28 | listFolders(store.getDefaultFolder(), ""); |
29 | |
30 | Folder inbox = store.getFolder("[Google Mail]/Sent Mail");
|
31 | inbox.open(Folder.READ_ONLY); |
32 | int idx = inbox.getMessageCount(); |
33 | print("Loading message " + idx);
|
34 | Message msg = inbox.getMessage(idx); |
35 | Address[] in = msg.getFrom(); |
36 | for (Address address : in) |
37 | print("FROM:" + address.toString());
|
38 | |
39 | print("Content type: " + getClassName(msg.getContent()));
|
40 | //BodyPart bp = mp.getBodyPart(0); |
41 | |
42 | System.out.println("To: "+InternetAddress.toString(msg.getRecipients(Message.RecipientType.TO)));
|
43 | System.out.println("Cc: "+InternetAddress.toString(msg.getRecipients(Message.RecipientType.CC)));
|
44 | System.out.println("Bcc: "+InternetAddress.toString(msg.getRecipients(Message.RecipientType.BCC)));
|
45 | System.out.println("SENT DATE:" + msg.getSentDate());
|
46 | System.out.println("SUBJECT:" + msg.getSubject());
|
47 | //System.out.println("CONTENT:" + bp.getContent());
|
48 | } |
49 | |
50 | svoid listFolders(Folder folder, S prefix) ctex {
|
51 | Folder[] folderList = folder.list(); |
52 | for (int i = 0; i < folderList.length; i++) {
|
53 | print(prefix + folderList[i].getFullName()); |
54 | listFolders(folderList[i], prefix + " "); |
55 | } |
56 | } |
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: | 1055 / 1105 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |