Ploblem with getContentText() method.

44 views
Skip to first unread message

Rodorush

unread,
Aug 15, 2012, 11:23:17 AM8/15/12
to gma...@googlegroups.com
Hello everybody,
I have the follow code, but I got a error at line with method getContentText(). Please could someone help me? Best regards.

package readgmail;

import com.googlecode.gmail4j.GmailClient;
import com.googlecode.gmail4j.GmailConnection;
import com.googlecode.gmail4j.GmailMessage;
import com.googlecode.gmail4j.auth.Credentials;
import com.googlecode.gmail4j.javamail.ImapGmailClient;
import com.googlecode.gmail4j.javamail.ImapGmailConnection;

public class ReadGmail {

public static void main(String[] args) {

GmailConnection conn = new ImapGmailConnection();
conn.setLoginCredentials(new Credentials("username", "password".toCharArray()));
GmailClient client = new ImapGmailClient();
client.setConnection(conn);
for (GmailMessage message : client.getUnreadMessages()) {
System.out.println(message.getFrom());
System.out.println(message.getSubject());
System.out.println(message.getContentText()); /* got error at this line as follow below:

Exception in thread "main" java.lang.UnsupportedOperationException: This GmailMessage implementation does not provide getContentText()
at com.googlecode.gmail4j.GmailMessage.getContentText(GmailMessage.java:199)
at lergmail.LerGmail.main(LerGmail.java:28)
Java Result: 1
*/
}
}
}

Reply all
Reply to author
Forward
0 new messages