Package javax.mail

Examples of javax.mail.Flags$Flag


   * not present implies that all flags in the required FLAGS
   * response can be changed permanently.
   */
  if (permanentFlags == null) {
      if (availableFlags != null)
    permanentFlags = new Flags(availableFlags);
      else
    permanentFlags = new Flags();
  }
    }
View Full Code Here


            if (count > 0) {
                Message[] messages;

                // should we process all messages or only unseen messages
                if (endpoint.getConfiguration().isProcessOnlyUnseenMessages()) {
                    messages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
                } else {
                    messages = folder.getMessages();
                }

                processMessages(messages);
View Full Code Here

        }
        return Collections.enumeration(nonMatchingHeaders);
    }

    public synchronized Flags getFlags() throws MessagingException {
        return new Flags(m_setFlags);
    }
View Full Code Here

     */
    protected Message[] searchForNewMessages(Folder folder) throws MessagingException {
        if (!folder.isOpen()) {
            return new Message[0];
        }
        Flags supportedFlags = folder.getPermanentFlags();
        SearchTerm searchTerm = null;
        if (supportedFlags != null) {
            if (supportedFlags.contains(Flags.Flag.RECENT)) {
                searchTerm = new FlagTerm(new Flags(Flags.Flag.RECENT), true);
            }
            if (supportedFlags.contains(Flags.Flag.ANSWERED)) {
                FlagTerm answeredTerm = new FlagTerm(new Flags(Flags.Flag.ANSWERED), false);
                if (searchTerm == null) {
                    searchTerm = answeredTerm;
                }
                else {
                    searchTerm = new AndTerm(searchTerm, answeredTerm);
                }
            }
            if (supportedFlags.contains(Flags.Flag.DELETED)) {
                FlagTerm deletedTerm = new FlagTerm(new Flags(Flags.Flag.DELETED), false);
                if (searchTerm == null) {
                    searchTerm = deletedTerm;
                }
                else {
                    searchTerm = new AndTerm(searchTerm, deletedTerm);
View Full Code Here

      MimeMessage message = new MimeMessage(service.getMailSession());
      message.setFrom(new InternetAddress(generateRandomEmailSender()));
      message.setRecipients(javax.mail.Message.RecipientType.TO, generateRandomEmailRecipient());
      message.setSubject(MAIL_SUBJECT);
      message.setContent(MAIL_CONTENTS, TEXT_PLAIN);
      Flags flags = new Flags();
      flags.add(Flags.Flag.RECENT);
      message.setFlags(flags, true);

      assertEquals("SMTP server should be now empty", 0, mailServer.getMessages().size());
      assertFalse(isEmailMessageSent(MAIL_SUBJECT));
      service.sendMessage(message);
View Full Code Here

    * We check if we can get real cause of exception, if that occurs during
    * message sending process.
    */
   public void testSendMimeMessageAsynchExceptionCause() throws Exception
   {
      Flags flags = new Flags();
      flags.add(Flags.Flag.RECENT);

      Properties props = new Properties(System.getProperties());
      props.putAll(service.getMailSession().getProperties());
      props.put("mail.smtp.port", SMTP_PORT + 1);
      Session session = Session.getInstance(props);
View Full Code Here

   public void testSendMimeMessageAsynch() throws Exception
   {
      @SuppressWarnings("unchecked")
      Future<Boolean>[] futures = new Future[THREAD_NUMBER];
      MimeMessage message;
      Flags flags = new Flags(Flags.Flag.RECENT);
      Session session = service.getMailSession();

      assertEquals("SMTP server should be now empty", 0, mailServer.getMessages().size());

      for (int i = 0; i < THREAD_NUMBER; i++)
View Full Code Here

            }
          }

          Message[] messages =
            messageList.toArray(new Message[messageList.size()]);
          folder.setFlags(messages, new Flags(Flags.Flag.DELETED), true);
          // clear the selection:
          _messagesTable.getSelectedRowKeys().clear();
          // refresh the folder so that the little 'deleted' icons show up:
          refresh();
        }
View Full Code Here

        startElement("message-number", attributes);
        characters(String.valueOf(message.getMessageNumber()));
        endElement("message-number");

        // FLAGS:
        Flags flags = message.getFlags();
        Flags.Flag[] sf = flags.getSystemFlags();
        // get the system flags

        attributes.clear();
        for (int i = 0; i < sf.length; i++) {
            Flags.Flag flag = sf[i];
            if (flag == Flags.Flag.ANSWERED) {
                addAttribute("answered", "yes");
            } else if (flag == Flags.Flag.DELETED) {
                addAttribute("deleted", "yes");
            } else if (flag == Flags.Flag.DRAFT) {
                addAttribute("draft", "yes");
            } else if (flag == Flags.Flag.FLAGGED) {
                addAttribute("flagged", "yes");
            } else if (flag == Flags.Flag.RECENT) {
                addAttribute("recent", "yes");
            } else if (flag == Flags.Flag.SEEN) {
                addAttribute("seen", "yes");
            }
        }
        startElement("flags", attributes);
        endElement("flags");

        String[] uf = flags.getUserFlags();
        // get the user flag strings
        for (int i = 0; i < uf.length; i++) {
            attributes.clear();
            startElement("user-flags", attributes);
            characters(uf[i]);
View Full Code Here

    // Retrieve the "Inbox"
    Folder inbox = store.getFolder("inbox");
    // Reading the Email Index in Read / Write Mode
    inbox.open(Folder.READ_WRITE);
    FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
    Message messages[] = inbox.search(ft);
    System.out.println(messages.length + " unread message");

    // Loop over all of the messages
    for (int i = messages.length - 1; i >= 0; i--) {
View Full Code Here

TOP

Related Classes of javax.mail.Flags$Flag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.