/**
*
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Tom
*
*/
public class outlook_1 {
/**
* @param args
*/
public static void main(String[] args) {
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]);
System.out.println("Appointment: " + calendarSubject.getString()
//+" Date Float: " + calendarStart.getFloat()
+" Date Double: " + calendarStart.getDouble()
//+" Date Long: " + calendarStart.getLong()
//+" Date String: " + calendarStart.getString()
+" Duration: " + calendarDuration.getInt());
calendarAutomation.dispose();
}
itemsAutomation.dispose();
defaultFolderAutomation.dispose();
mapiNamespaceAuto.dispose();
shell.dispose();
auto.dispose();
site.deactivateInPlaceClient();
site.dispose();
frm.dispose();
}
}