Created
October 10, 2010 14:26
-
-
Save nbqx/619274 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g100pon #13 gmailからメールを受信する | |
// IMAPでメールのリストつくるまであとはお好みで出力的なかんじです | |
import javax.mail.Session | |
import javax.mail.Folder | |
import java.util.Properties | |
@Grab(group="javax.mail", module="mail", version="latest.integration") | |
def user = "[email protected]" | |
def passwd = "your_password" | |
def props = new Properties() | |
props.setProperty("mail.store.protocol", "imaps") | |
def session = Session.getDefaultInstance(props,null) | |
def store = session.getStore("imaps") | |
store.connect("imap.gmail.com", user, passwd) | |
def inbox = store.getFolder("INBOX") | |
inbox.open(Folder.READ_ONLY) | |
def messages = inbox.messages.collect{mes-> | |
[sentDate: mes.sentDate, subject:mes.subject, from: mes.from, content: mes.content] | |
} | |
//print messages as you like... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment