Package javax.mail

Examples of javax.mail.Store.connect()


    private void prepareMailbox() throws Exception {
        // connect to mailbox
        Mailbox.clearAll();
        JavaMailSenderImpl sender = new JavaMailSenderImpl();
        Store store = sender.getSession().getStore("imap");
        store.connect("localhost", 25, "claus", "secret");
        Folder folder = store.getFolder("INBOX");
        folder.open(Folder.READ_WRITE);
        folder.expunge();

        // inserts two messages with the SEEN flag
View Full Code Here


    private void prepareMailbox() throws Exception {
        // 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
View Full Code Here

            }

            if (this.popBeforeSmtp)
            {
                final Store store = session.getStore("pop3");
                store.connect(this.popHost, this.popUsername, this.popPassword);
            }
        }
        catch (final MessagingException me)
        {
            throw new EmailException(me);
View Full Code Here

  @Override
  public Collection<OutboundMessage> getMessagesToSend() throws Exception
  {
    List<OutboundMessage> retValue = new ArrayList<OutboundMessage>();
    Store s = this.mailSession.getStore();
    s.connect();
    Folder inbox = s.getFolder(getProperty("mailbox_name", "INBOX"));
    inbox.open(Folder.READ_WRITE);
    for (Message m : inbox.getMessages())
    {
      OutboundMessage om = new OutboundMessage(m.getSubject(), m.getContent().toString());
View Full Code Here

    {
      // login to the IMAP server
      Properties props = new Properties();
      Session session = Session.getInstance(props, null);
      Store store = session.getStore("imap");
      store.connect(_server, _username, _password);
      setStore(store);

      setRootFolders(FolderData.toFolderData(this, store.getDefaultFolder().list()));

      // TODO: Add logged in indicator to restrict access
View Full Code Here

                storeURLNameExpanded = getURLNameExpanded(storeURLNameTemplate, userid, password);

                URLName urlNameExpanded = new URLName(storeURLNameExpanded);
                getLogger().info("get store using URLName " + String.valueOf(urlNameExpanded));
                mailStore = mailSession.getStore(urlNameExpanded);
                mailStore.connect();
                mailContext.put(MailContext.MAIL_STORE_ENTRY, mailStore);
            }
        } catch (Exception e) {
            String message = "Cannot get store, and connect " + String.valueOf(storeURLNameExpanded);
            getLogger().error(message, e);
View Full Code Here

        try {
            Session sess = Session.getDefaultInstance(this.props, null);
            Store st = sess.getStore("imap");

            log("Connecting to IMAP server @ " + this.host);
            st.connect(this.host, this.user, this.pass);

            log("Attempting to open default folder");
            Folder f = st.getFolder("inbox");

            f.open(Folder.READ_WRITE);
View Full Code Here

public class JavaMailConnection extends JavaMailSenderImpl {

    public Folder getFolder(String protocol, String folderName) {
        try {
            Store store = getSession().getStore(protocol);
            store.connect(getHost(), getPort(), getUsername(), getPassword());
            return store.getFolder(folderName);
        } catch (MessagingException e) {
            throw new MailSendException("Mail server connection failed", e);
        }
    }
View Full Code Here

    final String TEAMMATES_APP_URL = "You can view the result here: " + Config.inst().TEAMMATES_LIVE_SITE;
    final String TEAMMATES_APP_SIGNATURE = "If you encounter any problems using the system, email TEAMMATES support";

    Session sessioned = Session.getDefaultInstance(System.getProperties(), null);
    Store store = sessioned.getStore("imaps");
    store.connect("imap.gmail.com", gmail, password);

    // Retrieve the "Inbox"
    Folder inbox = store.getFolder("inbox");
    // Reading the Email Index in Read / Write Mode
    inbox.open(Folder.READ_WRITE);
View Full Code Here

        + Config.inst().TEAMMATES_LIVE_SITE;
    final String TEAMMATES_APP_SIGNATURE = "If you encounter any problems using the system, email TEAMMATES support";

    Session sessioned = Session.getDefaultInstance(System.getProperties(), null);
    Store store = sessioned.getStore("imaps");
    store.connect("imap.gmail.com", gmail, password);

    // Retrieve the "Inbox"
    Folder inbox = store.getFolder("inbox");
    // Reading the Email Index in Read / Write Mode
    inbox.open(Folder.READ_WRITE);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.