List of usage examples for javax.mail Message setFlags
public abstract void setFlags(Flags flag, boolean set) throws MessagingException;
From source file:com.sonicle.webtop.mail.Service.java
private boolean _flagAnsweredMessage(MailAccount account, String foldername, long uid) throws MessagingException { Message msg = null; SonicleIMAPFolder sifolder = (SonicleIMAPFolder) account.getFolder(foldername); sifolder.open(Folder.READ_WRITE);//ww w . ja va2s .co m msg = sifolder.getMessageByUID(uid); boolean found = msg != null; if (found) { msg.setFlags(FolderCache.repliedFlags, true); } sifolder.close(true); return found; }
From source file:com.sonicle.webtop.mail.Service.java
private boolean _flagForwardedMessage(MailAccount account, String foldername, long uid) throws MessagingException { Message msg = null; SonicleIMAPFolder sifolder = (SonicleIMAPFolder) account.getFolder(foldername); sifolder.open(Folder.READ_WRITE);/*w ww . j a v a 2s . co m*/ msg = sifolder.getMessageByUID(uid); boolean found = msg != null; if (found) { msg.setFlags(FolderCache.forwardedFlags, true); } sifolder.close(true); return found; }
From source file:com.sonicle.webtop.mail.Service.java
public void processSaveMessageNote(HttpServletRequest request, HttpServletResponse response, PrintWriter out) { MailAccount account = getAccount(request); String pfoldername = request.getParameter("folder"); String puidmessage = request.getParameter("idmessage"); String text = request.getParameter("text").trim(); UserProfile profile = environment.getProfile(); Connection con = null;//from w w w .j ava2 s . c o m boolean result = false; String message = ""; try { account.checkStoreConnected(); FolderCache mcache = account.getFolderCache(pfoldername); long msguid = Long.parseLong(puidmessage); Message msg = mcache.getMessage(msguid); String id = getMessageID(msg); con = getConnection(); NoteDAO.getInstance().deleteById(con, profile.getDomainId(), id); if (text.length() > 0) { ONote onote = new ONote(profile.getDomainId(), id, text); NoteDAO.getInstance().insert(con, onote); msg.setFlags(flagNote, true); } else { msg.setFlags(flagNote, false); } result = true; } catch (Exception exc) { Service.logger.error("Exception", exc); message = exc.getMessage(); } finally { DbUtils.closeQuietly(con); } new JsonResult(result, message).printTo(out); }
From source file:nl.ordina.bag.etl.mail.loader.IMAPMutatiesFileLoader.java
@Override public void processMessages() { try {/* w w w .j a v a2s.c om*/ Session session = Session.getDefaultInstance(new Properties(), null); Store store = session.getStore(protocol); if (port == 0) store.connect(host, username, password); else store.connect(host, port, username, password); Folder folder = store.getFolder(folderName); if (folder == null) throw new RuntimeException("Folder " + folderName + " not found!"); folder.open(Folder.READ_WRITE); try { FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false); Message messages[] = folder.search(ft); for (Message message : messages) { messageHandler.handle(message); message.setFlags(new Flags(Flags.Flag.SEEN), true); } } finally { folder.close(true); store.close(); } } catch (MessagingException | IOException | JAXBException e) { throw new ProcessingException(e); } }
From source file:nl.ordina.bag.etl.mail.loader.POP3MutatiesFileLoader.java
@Override public void processMessages() { try {//w w w . j ava 2 s . c o m Session session = Session.getDefaultInstance(new Properties(), null); Store store = session.getStore(protocol); if (port == 0) store.connect(host, username, password); else store.connect(host, port, username, password); Folder folder = store.getFolder(folderName); if (folder == null) throw new RuntimeException("Folder " + folderName + " not found!"); folder.open(Folder.READ_WRITE); try { Message[] messages = folder.getMessages(); for (Message message : messages) { backup(message); messageHandler.handle(message); message.setFlags(new Flags(Flags.Flag.DELETED), true); } } finally { folder.close(true); store.close(); } } catch (MessagingException | IOException | JAXBException e) { throw new ProcessingException(e); } }
From source file:org.springframework.integration.mail.AbstractMailReceiver.java
private void setMessageFlags(Message[] filteredMessages) throws MessagingException { boolean recentFlagSupported = false; Flags flags = this.getFolder().getPermanentFlags(); if (flags != null) { recentFlagSupported = flags.contains(Flags.Flag.RECENT); }/*from w w w. j a v a2s.c o m*/ for (Message message : filteredMessages) { if (!recentFlagSupported) { if (flags != null && flags.contains(Flags.Flag.USER)) { if (logger.isDebugEnabled()) { logger.debug("USER flags are supported by this mail server. Flagging message with '" + SI_USER_FLAG + "' user flag"); } Flags siFlags = new Flags(); siFlags.add(SI_USER_FLAG); message.setFlags(siFlags, true); } else { if (logger.isDebugEnabled()) { logger.debug( "USER flags are not supported by this mail server. Flagging message with system flag"); } message.setFlag(Flags.Flag.FLAGGED, true); } } this.setAdditionalFlags(message); } }