Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > TinyBrain | #1005141 - GMail: Show last mails in inbox

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 590K of libraries. Click here for Pure Java version (2475L/17K/62K).

!7

static int numMsgs = 10;

p {
  veryBigConsole();
  if (empty(gmailDefaultUser())) {
    print("Run #1005140 to set gmail user name!");
    ret;
  }
  
  Folder inbox = gmail_inbox();
  printLastMails(inbox);
}

svoid printLastMails(Folder inbox) ctex {
  inbox.open(Folder.READ_ONLY);
  int count = inbox.getMessageCount();
  for (int i = count; i >= max(1, count-numMsgs+1); i--) {
    print("\nLoading message " + i + "\n");
    Message msg = inbox.getMessage(i);
    print("  From: " + InternetAddress.toString(msg.getFrom()));
    print("  Subject: " + msg.getSubject());
    print("  Message number: " + msg.getMessageNumber());
    print("  Sent/Received: " + msg.getSentDate() + "/" + msg.getReceivedDate());
    //print("  Class: " + getClassName(msg));
    //O content = msg.getContent();
    //print("  Content type: " + getClassName(content));
    print("  Size: " + msg.getSize());
    print("  Content type: " + msg.getContentType());
  }
}

Author comment

Began life as a copy of #1003302

download  show line numbers  debug dex   

Travelled to 3 computer(s): cfunsshuasjs, ddnzoavkxhuk, tvejysmllsmz

No comments. add comment

Snippet ID: #1005141
Snippet name: GMail: Show last mails in inbox
Eternal ID of this version: #1005141/14
Text MD5: f31c9f6578e977690365c7cde6f81b2a
Transpilation MD5: d9ddef794add9bd65056ee5995adad64
Author: stefan
Category: javax / gmail
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-21 17:43:02
Source code size: 989 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 110 / 164
Version history: 13 change(s)
Referenced in: [show]