Package javax.mail

Examples of javax.mail.Folder


        try
        {
            //get folder destination

            //Folder to_folder = store.getFolder("myfolder/"+toFolder);
            Folder to_folder = store.getFolder(toFolder);
            Folder from_folder = store.getFolder(fromFolder);

            from_folder.open(Folder.READ_WRITE);

            int tempStart = checkboxes.length;
            int startvalue = Integer.parseInt(checkboxes[tempStart - 1]);
            int start = startvalue + 1;

            int tempEnd = Integer.parseInt(checkboxes[0]);
            int end = tempEnd + 1;

            to_folder.open(Folder.READ_WRITE);
            // get the message
            Message msge[] = from_folder.getMessages(start, end);
            from_folder.copyMessages(msge, to_folder);
            from_folder.close(true);

            //delete the message from inbox folder
            String protocol = (String) parameters.get("protocol");

            checkboxDelete(fromFolder, checkboxes, protocol);
View Full Code Here


    {
        try
        {
            //get folder destination
            //Folder dfolder = store.getFolder("myfolder/"+toFolder);
            Folder dfolder = store.getFolder(toFolder);
            Folder from_folder = store.getFolder(fromFolder);

            from_folder.open(Folder.READ_WRITE);
            dfolder.open(Folder.READ_WRITE);

            // get the message
            Message msge[] = from_folder.getMessages(current_index + 1,
                    current_index + 1);
            from_folder.copyMessages(msge, dfolder);
            //from_folder.close(true);

            //delete the message from inbox folder
            String protocol = (String) parameters.get("protocol");
View Full Code Here

    {
        Vector message_folder = new Vector();

        try
        {
            Folder fname = store.getFolder(foldername);
            fname.open(Folder.READ_ONLY);

            Message message[] = fname.getMessages();
            for (int i = 0; i < message.length; i++)
            {
                Message msge = message[i];

                boolean withAttachment = checkAttachment(msge);
View Full Code Here

    {
        try
        {
            //Folder current_folder =
            // store.getFolder("myfolder/"+folder_name);
            Folder current_folder = store.getFolder(folder_name);
            //current_folder.open(Folder.READ_WRITE);
            current_folder.delete(true);

        } catch (Exception e)
        {
            log.error("Error in folderDelete()",e);
        }
View Full Code Here

    public Folder getFolder(String folder_name)
    {
        try
        {
            Folder current_folder = store.getFolder(folder_name);
            return current_folder;
        } catch (Exception e)
        {
            log.error("Error in getFolder()",e);
            return null;
View Full Code Here

        {
            message = email.getMessage(current_index);
        } else
        {
            message = email.getMessage(current_index, folder_name);
            Folder current_folder = email.getFolder(folder_name);

        }

        String subject = email.getSubject(message);
        String from = email.getFrom(message);
View Full Code Here

            // Get the store
            Store store = session.getStore(getServerType());
            store.connect(getServer(), getPortAsInt(), getUserName(), getPassword());

            // Get folder
            Folder folder = store.getFolder(getFolder());
            if (deleteMessages) {
                folder.open(Folder.READ_WRITE);
            } else {
                folder.open(Folder.READ_ONLY);
            }

            // Get directory
            Message messages[] = folder.getMessages();
            StringBuilder pdata = new StringBuilder();
            pdata.append(messages.length);
            pdata.append(" messages found\n");
            parent.setResponseData(pdata.toString(),null);
            parent.setDataType(SampleResult.TEXT);
            parent.setContentType("text/plain"); // $NON-NLS-1$

            int n = getNumMessages();
            if (n == ALL_MESSAGES || n > messages.length) {
                n = messages.length;
            }

            parent.setSampleCount(n); // TODO is this sensible?

            busy = true;
            for (int i = 0; busy && i < n; i++) {
                StringBuilder cdata = new StringBuilder();
                SampleResult child = new SampleResult();
                child.sampleStart();
                Message message = messages[i];

                cdata.append("Message "); // $NON-NLS-1$
                cdata.append(message.getMessageNumber());
                child.setSampleLabel(cdata.toString());
                child.setSamplerData(cdata.toString());
                cdata.setLength(0);

                final String contentType = message.getContentType();
                child.setContentType(contentType);// Store the content-type
                child.setDataEncoding(RFC_822_DEFAULT_ENCODING); // RFC 822 uses ascii per default
                child.setEncodingAndType(contentType);// Parse the content-type

                if (isStoreMimeMessage()) {
                    // Don't save headers - they are already in the raw message
                    ByteArrayOutputStream bout = new ByteArrayOutputStream();
                    message.writeTo(bout);
                    child.setResponseData(bout.toByteArray()); // Save raw message
                    child.setDataType(SampleResult.TEXT);
                } else {
                    @SuppressWarnings("unchecked") // Javadoc for the API says this is OK
                    Enumeration<Header> hdrs = message.getAllHeaders();
                    while(hdrs.hasMoreElements()){
                        Header hdr = hdrs.nextElement();
                        String value = hdr.getValue();
                        try {
                            value = MimeUtility.decodeText(value);
                        } catch (UnsupportedEncodingException uce) {
                            // ignored
                        }
                        cdata.append(hdr.getName()).append(": ").append(value).append("\n");
                    }
                    child.setResponseHeaders(cdata.toString());
                    cdata.setLength(0);
                    appendMessageData(child, message);
                }

                if (deleteMessages) {
                    message.setFlag(Flags.Flag.DELETED, true);
                }
                child.setResponseOK();
                if (child.getEndTime()==0){// Avoid double-call if addSubResult was called.
                    child.sampleEnd();
                }
                parent.addSubResult(child);
            }

            // Close connection
            folder.close(true);
            store.close();

            parent.setResponseCodeOK();
            parent.setResponseMessageOK();
            isOK = true;
View Full Code Here

        // connect to mailbox
        Mailbox.clearAll();
        JavaMailSenderImpl sender = new JavaMailSenderImpl();
        Store store = sender.getSession().getStore("pop3");
        store.connect("localhost", 25, "jones", "secret");
        Folder folder = store.getFolder("INBOX");
        folder.open(Folder.READ_WRITE);
        folder.expunge();

        // inserts 8 new messages
        Message[] messages = new Message[5];
        for (int i = 0; i < 5; i++) {
            messages[i] = new MimeMessage(sender.getSession());
            messages[i].setText("Message " + i);
        }
        folder.appendMessages(messages);
        folder.close(true);
    }
View Full Code Here

        // connect to mailbox
        Mailbox.clearAll();
        JavaMailSenderImpl sender = new JavaMailSenderImpl();
        Store store = sender.getSession().getStore("pop3");
        store.connect("localhost", 25, "jones", "secret");
        Folder folder = store.getFolder("INBOX");
        folder.open(Folder.READ_WRITE);
        folder.expunge();

        // inserts 5 new messages
        Message[] messages = new Message[5];
        for (int i = 0; i < 5; i++) {
            messages[i] = new MimeMessage(sender.getSession());
            messages[i].setText("Message " + i);
        }
        folder.appendMessages(messages);
        folder.close(true);
    }
View Full Code Here

      myLog.warn ("either output directory or send to email address need to be specified.");
      return false;
    }

    try {
      Folder inbox = getMailClient ().openInboxFolder ();
      if (inbox != null) {
        inbox.getMessageCount ();
      }
      else {
        myLog.error ("checkConfig - inbox folder is null");
      }
    }
View Full Code Here

TOP

Related Classes of javax.mail.Folder

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.