private static void readCalendar() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Outlook Automation");
shell.setLayout(new FillLayout());
OleFrame frm = new OleFrame(shell, SWT.NONE);
OleClientSite site = new OleClientSite(frm, SWT.NONE,
"Outlook.Application");
site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
OleAutomation auto = new OleAutomation(site);
int[] GetNamespaceDispId = auto
.getIDsOfNames(new String[] { "GetNamespace" });
Variant mapiNamespace = auto.invoke(GetNamespaceDispId[0],
new Variant[] { new Variant("MAPI") });
OleAutomation mapiNamespaceAuto = mapiNamespace.getAutomation();
int[] DefaultFolderPropertyDispId = mapiNamespaceAuto
.getIDsOfNames(new String[] { "GetDefaultFolder" });
Variant defaultFolder = mapiNamespaceAuto.invoke(
DefaultFolderPropertyDispId[0],
new Variant[] { new Variant(9) });
OleAutomation defaultFolderAutomation = defaultFolder.getAutomation();
int[] ItemsFolderPropertyDispId = defaultFolderAutomation
.getIDsOfNames(new String[] { "Items" });
Variant items = defaultFolderAutomation
.invoke(ItemsFolderPropertyDispId[0]);
OleAutomation itemsAutomation = items.getAutomation();
int[] ItemsCountPropertyDispId = itemsAutomation
.getIDsOfNames(new String[] { "Count" });
int[] itemDispId = itemsAutomation
.getIDsOfNames(new String[] { "Item" });
Variant itemsCount = itemsAutomation
.invoke(ItemsCountPropertyDispId[0]);
for (int i = 1, cnt = itemsCount.getInt(); i <= cnt; i++) {
Variant calendar = itemsAutomation.invoke(itemDispId[0],
new Variant[] { new Variant(i) });
OleAutomation calendarAutomation = calendar.getAutomation();
int[] CalendarSubjectPropertyDispId = calendarAutomation
.getIDsOfNames(new String[] { "Subject" });
Variant calendarSubject = calendarAutomation
.getProperty(CalendarSubjectPropertyDispId[0]);
int[] CalendarStartPropertyDispId = calendarAutomation
.getIDsOfNames(new String[] { "Start" });
Variant calendarStart = calendarAutomation
.getProperty(CalendarStartPropertyDispId[0]);
int[] CalendarDurationPropertyDispId = calendarAutomation
.getIDsOfNames(new String[] { "Duration" });
Variant calendarDuration = calendarAutomation
.getProperty(CalendarDurationPropertyDispId[0]);
int[] CalendarEndPropertyDispId = calendarAutomation
.getIDsOfNames(new String[] { "End" });
Variant calendarEnd = calendarAutomation
.getProperty(CalendarEndPropertyDispId[0]);
System.out.println("Appointment: " + calendarSubject.getString()
+" Start: " + calendarStart.getDouble()
+" Start: " + calendarStart.toString()
+" End: " + calendarEnd.getDouble()
+" Duration: " + calendarDuration.getInt());
calendarAutomation.dispose();
}