Я написал скрипт (на груви ), который создаёт метку "Big Mail" и маркирует ей все письма размером больше чем 4Мб. В скрипте надо заменить имя юзера и пароль в Gmail, а также, если хотите, размер "больших" мейлов.
Для работы скрипта в classpath должны быть jars отсюда.
Итерация по сообщениям медленная (1-2 в секунду), так что я поставил печать номера просматриваемого письма, чтобы вы знали, что скрипт не застрял.
Не забудьте сделать IMAP - enable в Settings Гмаила
P.S. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY
// Mark large email messages in Gmail by "Bim Mail" label. // (c) Pavel Bernshtam, javaap@gmail.com // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY import java.security.NoSuchProviderException import javax.mail.* final int BIG_MAIL_SIZE = 2 ** 22 //4Mb final String username = "xxx" final String password = "xxx" Properties props = System.getProperties() props.setProperty("mail.store.protocol", props.setProperty("mail.imap.socketFacto props.setProperty("mail.imap.socketFacto Folder all, big Store store try { Session session = Session.getDefaultInstance(props, null) store = session.getStore("imaps") final String mailaddress = "$username@gmail.com" store.connect("imap.gmail.com", mailaddress, password) def folderName = "[Gmail]/All Mail" all = store.getFolder(folderName) all.open(Folder.READ_WRITE); println("Creating BigMail ...") big = store.getFolder("BigMail") if (big.create(Folder.HOLDS_MESSAGES)) println "Ok." else println "Failure. Already exists?" big.open(Folder.READ_WRITE); println "Downloading from folder $folderName ...." List println "Got ${messages.size()} messages" int count = 0 messages.each { int size = it.getSize(); if (size > BIG_MAIL_SIZE) { println "$count: Big mail: ${it.getSubject()} (${it.getSize()})" all.copyMessages([it].toArray(new Message[1]), big) } else { println count } count++ } } catch (NoSuchProviderException e) { e.printStackTrace(); System.exit(1); } catch (MessagingException e) { e.printStackTrace(); System.exit(2); } finally { // Close connection all.close(false) big.close(false) store.close() } |