Gmail4J - accessing Gmail services from Java

Written by Markus Eisele
08:51
Gmail4J is a simple, object oriented library for accessing Gmail services from Java. The actual build version 0.3 is available under a Apache License 2.0 from code.google.com.

You can use it with maven (Java.net Repository):

<dependency>
<groupId>com.googlecode</groupId>
<artifactId>gmail4j</artifactId>
<version>0.3</version>
</dependency>


Some example code? Get unread Messages from your account (through proxy):

GmailClient client = new RssGmailClient();
GmailConnection connection = new HttpGmailConnection(LoginDialog.getInstance().show("Enter Gmail Login"));
connection.setProxy("proxy.example.com", 8080);
client.setConnection(connection);
final List messages = client.getUnreadMessages();
for (GmailMessage message : messages) {
System.out.println(message);
}


Looks like this:

Comments

Avatar
how to import library of gmail4j in java file.......
Gmail client not resolved to a type........error
Avatar
Hi,

Don't know if I can help you with that. You might want to check a more basic example about java that gets you started.

-m

The Main Thread

A thoughtful and pragmatic exploration of modern Enterprise Java, Quarkus, and AI that connects technology, architecture, and developer experience.

By Markus Eisele · Over 1,000 subscribers