Package javax.mail

Examples of javax.mail.Flags


      // DATE
      Date d = m.getSentDate();
      pr("SendDate: " + (d != null ? d.toString() : "UNKNOWN"), level);

      // FLAGS (not supported by POP3)
      Flags flags = m.getFlags();
      StringBuffer sb = new StringBuffer();
      Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags

      boolean first = true;
      for (int i = 0; i < sf.length; i++) {
         String s;
         Flags.Flag f = sf[i];
         if (f == Flags.Flag.ANSWERED)
            s = "\\Answered";
         else if (f == Flags.Flag.DELETED)
            s = "\\Deleted";
         else if (f == Flags.Flag.DRAFT)
            s = "\\Draft";
         else if (f == Flags.Flag.FLAGGED)
            s = "\\Flagged";
         else if (f == Flags.Flag.RECENT)
            s = "\\Recent";
         else if (f == Flags.Flag.SEEN)
            s = "\\Seen";
         else
            continue; // skip it
         if (first)
            first = false;
         else
            sb.append(' ');
         sb.append(s);
      }

      String[] uf = flags.getUserFlags(); // get the user flag strings
      for (int i = 0; i < uf.length; i++) {
         if (first)
            first = false;
         else
            sb.append(' ');
View Full Code Here


  // ---------------------------------------------------------------------------

  public static Flags getFlags(MimeMessage oMsg)
    throws MessagingException {
    Flags oFlgs = oMsg.getFlags();
    if (oFlgs==null) oFlgs = new Flags();
    return oFlgs;
  }
View Full Code Here

    Object oFlag;

    if (oFolder==null)
      return super.getFlags();
    else {
      Flags oRetVal = null;
      Statement oStmt = null;
      ResultSet oRSet = null;
      try {
        Flags.Flag[] aFlags = new Flags.Flag[]{Flags.Flag.RECENT, Flags.Flag.ANSWERED, Flags.Flag.DELETED, Flags.Flag.DRAFT, Flags.Flag.FLAGGED, Flags.Flag.SEEN};
        oStmt = ( (DBFolder) oFolder).getConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        oRSet = oStmt.executeQuery("SELECT "+DB.bo_recent+","+DB.bo_answered+","+DB.bo_deleted+","+DB.bo_draft+","+DB.bo_flagged+","+DB.bo_recent+","+DB.bo_seen+" FROM "+DB.k_mime_msgs+" WHERE "+DB.gu_mimemsg+"='"+getMessageGuid()+"'");
        if (oRSet.next()) {
          oRetVal = new Flags();
          for (int f=1; f<=6; f++) {
            oFlag = oRSet.getObject(f);
            if (!oRSet.wasNull()) {
              if (oFlag.getClass().equals(Short.TYPE)) {
                if (((Short) oFlag).shortValue()==(short)1)
                  oRetVal.add(aFlags[f-1]);
              }
              else {
                if (Integer.parseInt(oFlag.toString())!=0)
                  oRetVal.add(aFlags[f-1]);
              }
            }
          } // next (f)
        }
        oRSet.close();
View Full Code Here

    if (DebugFile.trace) {
      DebugFile.writeln("Begin DBMimeMessage.saveChanges()");
      DebugFile.incIdent();
    }

    Flags oFlgs = getFlags();

    if (oFolder instanceof DBFolder) {
      JDCConnection oConn = null;
      try {
        oConn.commit();
View Full Code Here

  } // getParent

  // ---------------------------------------------------------------------------

  public Flags getPermanentFlags() {
    Flags oFlgs = new Flags();
    oFlgs.add(Flags.Flag.DELETED);
    oFlgs.add(Flags.Flag.ANSWERED);
    oFlgs.add(Flags.Flag.DRAFT);
    oFlgs.add(Flags.Flag.SEEN);
    oFlgs.add(Flags.Flag.RECENT);
    oFlgs.add(Flags.Flag.FLAGGED);

    return oFlgs;
  }
View Full Code Here

        return set;
    }

    public boolean match(Message message) {
        try {
            Flags msgFlags = message.getFlags();
            if (set) {
                return msgFlags.contains(flags);
            } else {
                // yuk - I wish we could get at the internal state of the Flags
                Flags.Flag[] system = flags.getSystemFlags();
                for (int i = 0; i < system.length; i++) {
                    Flags.Flag flag = system[i];
                    if (msgFlags.contains(flag)) {
                        return false;
                    }
                }
                String[] user = flags.getUserFlags();
                for (int i = 0; i < user.length; i++) {
                    String flag = user[i];
                    if (msgFlags.contains(flag)) {
                        return false;
                    }
                }
                return true;
            }
View Full Code Here

     * @param session the session for this message
     */
    public MimeMessage(Session session) {
        super(session);
        headers = new InternetHeaders();
        flags = new Flags();
        modified = true;
    }
View Full Code Here

     * @param number the message number of the new message
     */
    protected MimeMessage(Folder folder, int number) {
        super(folder, number);
        headers = new InternetHeaders();
        flags = new Flags();
        modified = true;
    }
View Full Code Here

        }
      }

      try {
        tmpEmailConn.currentFolder.getFolder().setFlags(msgnumbers,
                                               new Flags(Flags.Flag.DELETED),false);
      } catch (MessagingException e) {
        handleFatalError(hr,"Deleting messages", e);
        return;
      }
    } else if ("deletemsg".equals(hr.get("action"))) {
      /* Mark the msgnum(s) as deleted */
     
      msgNum = hr.get("msgnum");
      msglist = new StringTokenizer(msgNum,", ");
      msgnumbers = new int[msglist.countTokens()];

      hr.request.log(Server.LOG_DIAGNOSTIC,connHandle,"Messages to delete: " + msgNum);

      while (msglist.hasMoreTokens()) {
        try {
          msgnumbers[i] = Integer.parseInt(msglist.nextToken());
          i++;
        } catch (NumberFormatException e) {
          /* Just skip this particular token */
   
          continue;
        }
      }

      try {
        tmpEmailConn.currentFolder.getFolder().setFlags(msgnumbers,
                                               new Flags(Flags.Flag.DELETED),true);
      } catch (MessagingException e) {
        handleFatalError(hr,"Deleting messages", e);
        return;
      }
    } else if ("refilemsg".equals(hr.get("action"))) {
View Full Code Here

          tmpMsgs = tmpRefile.tmpEmailConn.currentFolder.getMessageObjects(hr,
                    tmpRefile.msgList.toString().trim());

          tmpRefile.tmpEmailConn.currentFolder.getFolder().copyMessages(tmpMsgs,tmpFolder);
          tmpRefile.tmpEmailConn.currentFolder.getFolder().setFlags(tmpMsgs,
                                                           new Flags(Flags.Flag.DELETED),
                                                           true);
        } catch (FolderNotFoundException e) {
          props.put(connHandle + "mailError","Folder: " + tmpKey + " was not found");

          hr.request.log(Server.LOG_DIAGNOSTIC,connHandle,"Folder: " + tmpKey + " not found");
View Full Code Here

TOP

Related Classes of javax.mail.Flags

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.