Looking for unread emails in a user's inbox

This short example explains how to show a count of unread mails in a Blue Mind user's inbox in an enterprise portal.

Overview

The steps to fetch the unread mails count using an admin0 API key are:

Code sample

		String bmCoreUrl = "https://bjday/services";

		// create an IMail client
		MailLocator ml = new MailLocator();
		MailClient mail = ml.locate(bmCoreUrl);

		// login with the API key
		AccessToken token = mail.login("admin0@global.virt", key, "junit-"
				+ getName());

		// create a session a another user
		AccessToken asUser = mail.sudo(token, "admin@willow.vmw");

		// fetch the unread mail count
		int unreadCount = mail.getUnreadMailCount(asUser);
		System.out.println("Unread emails count is " + unreadCount);

		// and logout
		mail.logout(asUser);