0
мне нужно архивировать/хранить Gmail форма электронной почты Java, но я знаю только установить его на чтение/непрочитанных ...Как я архивировать электронную почту, используя javax почту
Вот мой код:
public class CheckingMails {
private static Session session = null;
private static Store store = null;
private static Folder inbox = null;
public static void check(String host, String storeType, final String user,
final String password)
{
try {
Properties properties = new Properties();
properties.setProperty("mail.host", "imap.gmail.com");
properties.setProperty("mail.port", "995");
properties.setProperty("mail.transport.protocol", "imaps");
session = Session.getInstance(properties,new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}});
store = session.getStore("imaps");
store.connect();
inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_WRITE);
Message messages[] = inbox.search(new FlagTerm(new Flags(Flag.SEEN), false));
for (int i = 0; i < messages.length; i++) {
if(messages[i].getSubject().contains("Ticket#")){
System.out.println("Number of Ticket = " + messages.length);
messages[i].setFlag(Flag.SEEN, true);
}
}
inbox.close(true);
store.close();
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
Может кто-нибудь объяснить мне, как я могу его архивировать?