A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
public class TestConnect {
public static void main(String[] args){
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
ExchangeCredentials credentials = new WebCredentials("address@server.net", "password");
service.setCredentials(credentials);
try {
service.autodiscoverUrl("address@server.net");
ItemView view = new ItemView(10);
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Inbox, view);
for (Item item : findResults.getItems()) {
// Do something with the item as shown
System.out.println("id==========" + item.getId());
System.out.println("sub==========" + item.getSubject());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
<dependency>
<groupId>com.microsoft.ews-java-api</groupId>
<artifactId>ews-java-api</artifactId>
<version>2.0</version>
</dependency>
private static void searchCalendars (ExchangeService service, ArrayList<OutlookCalendar> output, ArrayList<Folder> folders, String sangria) {
try {
System.out.println(sangria+"The count of Subfolders: "+folders.size());
int counter = 1;
for (Folder folder : folders) {
if (folder instanceof CalendarFolder) {
System.out.println(sangria+"#" + counter + " \"" + folder.getDisplayName() + "\" is a calendar folder!");
System.out.println(sangria+"-----> Found calendar named \"" + folder.getDisplayName() + "\" which has "+folder.getTotalCount()+" appointment(s) and id: " + folder.getId() + "\n");
output.add(new OutlookCalendar(folder.getId().getUniqueId(), folder.getDisplayName()));
FindFoldersResults next = service.findFolders(folder.getId(), new FolderView(Integer.MAX_VALUE));
searchCalendars (service, output, next.getFolders(), sangria+"\t");
}
else {
if (folder.getChildFolderCount() > 0) {
System.out.println(sangria+"#" + counter + " \"" +folder.getDisplayName() + "\" is not a calendar folder but it has "+folder.getChildFolderCount()+" subfolders. We resume the search inside this folder... ");
try {
FindFoldersResults result = service.findFolders(folder.getId(), new FolderView(Integer.MAX_VALUE));
searchCalendars (service, output, result.getFolders(), sangria+"\t");
}
catch (ServiceResponseException e) {
System.err.println(sangria+"Exception occurred: "+e.getMessage() + "\n");
}
}
else {
System.out.println(sangria+"#" + counter + " \"" +folder.getDisplayName() + "\" has 0 subfolders. Search in this folder finished!\n");
}
}
counter++;
}
}
catch (Exception e) {
System.out.println("Error searching appointments");
e.printStackTrace();
}
}
ErrorMeetingRequestIsOutOfDate
when I try to accept a meeting request via the java api...import java.net.URI;
import microsoft.exchange.webservices.data.core.ExchangeService;
import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
import microsoft.exchange.webservices.data.credential.ExchangeCredentials;
import microsoft.exchange.webservices.data.credential.WebCredentials;
import microsoft.exchange.webservices.data.property.complex.availability.OofSettings;
public class GetOOO {
public static void main(String[] args)
{
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setTraceEnabled(true);
service.setUrl(new URI("https://email.xxx.com/EWS/Exchange.asmx"));
ExchangeCredentials credentials = new WebCredentials("<<superUserId>>", "<<SuperUserPassword>>","XXX");
service.setCredentials(credentials);
OofSettings myOOFSettings = service.getUserOofSettings("<<emailId>>");
System.out.println(myOOFSettings.getState());
service.close();
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
Hi guys. Can anyone help me with a question, please? I am playing around with EWS Java Api and currently I'm trying to understand one thing.
If I loop through some items in Sent Items folder, I won't see any Emails that have: getIsFromMe() == true or getIsSubmitted() == true.
As per docs:
getIsFromMe():
getIsSubmitted():