Moyosoft Products | Services | Download | Contact us    
Java Bridge to Exchange
import java.text.*;
import java.util.*;

import com.moyosoft.exchange.*;
import com.moyosoft.exchange.calendar.*;
import com.moyosoft.exchange.folder.*;
import com.moyosoft.exchange.item.*;

public class DisplayAppointments
{
  public static void main(String[] argsthrows ExchangeServiceException
  {
    // To provide hostname and credentials information, use:
    // Exchange exchange = new Exchange("hostname", "username", "password");
    Exchange exchange = ExchangeConnectionDialog.display();
    
    if(exchange == null)
    {
      return;
    }

    // Get the default Calendar folder
    ExchangeFolder calendar = exchange.getCalendarFolder();

    Date now = new Date();
    Date oneDayAgo = new Date(now.getTime() 86400000);
    
    // Get the appointments occuring in the last 24h:
    Iterable<ExchangeItem> items = calendar.getItems().iterableForCalendar(oneDayAgo, now);
    
    for(ExchangeItem item : items)
    {
      ExchangeCalendarItem appointment = (ExchangeCalendarItemitem;

      System.out.println("Subject: " + appointment.getSubject());
      System.out.println("Location: " + appointment.getLocation());
      System.out.println("Start: " + formatDateToString(appointment.getStart()));
      System.out.println("End: " + formatDateToString(appointment.getEnd()));
      System.out.println();
    }
  }

  private static String formatDateToString(Date date)
  {
    return new SimpleDateFormat().format(date);
  }
}