Package com.googlecode.gmail4j.javamail

Examples of com.googlecode.gmail4j.javamail.ImapGmailClient


        }
    }
   
    @Test
    public void testGetContentText() {
        final ImapGmailClient client = new ImapGmailClient(ImapGmailLabel.SENT_MAIL);
        final ImapGmailConnection connection = new ImapGmailConnection();

        try {
            connection.setLoginCredentials(conf.getGmailCredentials());
            if (conf.useProxy()) {
                connection.setProxy(conf.getProxyHost(), conf.getProxyPort());
                connection.setProxyCredentials(conf.getProxyCredentials());
            }
            client.setConnection(connection);
           
            // Send a message so we have one
            GmailMessage msg = new JavaMailGmailMessage();
            msg.setSubject("Test mail subject. Unicode: ąžuolėlį");
            msg.setContentText("Test mail content. Unicode: ąžuolėlį");
            msg.addTo(new EmailAddress(conf.getTestRecipient()));
            client.send(msg);
           
            log.debug("Getting messages");
            final List<GmailMessage> messages = client.getUnreadMessages();
            log.debug("Got " + messages.size() + " messages");
            for (GmailMessage message : messages) {
                String text = message.getContentText();
                log.debug("Got text: " + text);
                assertTrue("Text is not empty", text.length() > 0);
            }
            assertNotNull("Messages are not null", messages);
        } catch (final Exception e) {
            log.error("Test Failed", e);
            fail("Caught exception: " + e.getMessage());
        } finally {
            client.disconnect();
        }
    }
View Full Code Here

TOP

Related Classes of com.googlecode.gmail4j.javamail.ImapGmailClient

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.