Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JGraph
>
Tutorial
> List all inbox messages
Retreive all inbox messages.
import java.util.List; import com.independentsoft.graph.GraphClient; import com.independentsoft.graph.GraphException; import com.independentsoft.graph.StandardMailboxFolder; import com.independentsoft.graph.mails.Message; import com.independentsoft.graph.queryoptions.Query; import com.independentsoft.graph.users.UserId; public class Console { public static void main(String[] args) { try { GraphClient client = new GraphClient(); client.setClientId("63333333-209e-454e-b7bd-55a4d201270f"); client.setTenant("independentsoft.onmicrosoft.com"); client.setClientSecret("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); int skip = 0; int top = 100; while (true) { Query query = new Query(); query.setTop(top); if (skip > 0) { query.setSkip(skip); } List
messages = client.getMessages(StandardMailboxFolder.INBOX, new UserId("info@independentsoft.onmicrosoft.com"), query); for (int i = 0; i < messages.size(); i++) { System.out.println("Id: " + messages.get(i).getId()); System.out.println("Subject: " + messages.get(i).getSubject()); System.out.println("ReceivedTime: " + messages.get(i).getReceivedTime()); System.out.println("----------------------------------------------------"); } if (messages.size() == 100) { skip = skip + 100; } else { break; } } } catch (GraphException e) { System.out.println(e.getCode()); System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*