com.moyosoft.connector.ms.outlook
Class Outlook

java.lang.Object
  |
  +--com.moyosoft.connector.ms.outlook.Outlook

public class Outlook
extends java.lang.Object

Provides access to the Outlook application. An Outlook object is the starting point for accessing Outlook, its folders and items.

The code using the Outlook class has to run on the computer where the Outlook application is installed. The default constructor connects to that Outlook application:

Outlook outlook = new Outlook();

Native resources used by the Outlook object should be disposed by calling the method dispose() of this class.

Usage example:

Outlook outlook = new Outlook();
System.out.println("Your Outlook version is: " + outlook.getOutlookVersion());
outlook.dispose();

See Also:
Outlook(), dispose()

Constructor Summary
Outlook()
          Default constructor.
Outlook(java.lang.String profile, java.lang.String password)
          Creates the Outlook object and logs on with the specified profile.
Outlook(java.lang.String profile, java.lang.String password, boolean showDialog, boolean newSession)
          Creates the Outlook object and logs on with the specified profile.
 
Method Summary
 void addStore(java.io.File storePstFile)
          Opens the specified PST file in a new Outlook folder.
 void addStore(java.io.File storePstFile, StoreType type)
          Opens the specified PST file in a new Outlook folder.
static Outlook createInstance(com.moyosoft.connector.com.ComManager comManager)
          Creates the Outlook object and logs on with the default profile.
static Outlook createInstance(com.moyosoft.connector.com.ComManager comManager, java.lang.String profile, java.lang.String password, boolean showDialog, boolean newSession)
          Creates the Outlook object and logs on with the specified profile.
 OutlookItem createItemFromTemplate(java.io.File templateFile)
          Creates an OutlookItem object from the specified .msg file.
 OutlookItem createItemFromTemplate(java.io.File templateFile, OutlookFolder destinationFolder)
          Creates an OutlookItem object from the specified .msg file and places that item in the specified destination folder.
 OutlookRecipient createRecipient(java.lang.String pRecipientName)
          Create a recipient object.
 void dial()
           
 void dial(OutlookContact contactToDial)
           
 void dispose()
          Dispose the outlook library.
 AccountsCollection getAccounts()
          Returns the Outlook accounts collection.
 Explorer getActiveExplorer()
          Returns the active (focused) Outlook Explorer window.
 Inspector getActiveInspector()
          Returns the active (focused) Outlook Inspector window.
 OutlookWindow getActiveWindow()
           
 AddressListsCollection getAddressLists()
           
 java.util.List getAllFolders()
          Deprecated. Use the getFolders() method instead.
 com.moyosoft.connector.com.Dispatch getApplicationDispatch()
           
 OutlookRecipient getCurrentUser()
          Returns the currently logged-on user as an OutlookRecipient object
 OutlookFolder getDefaultFolder(FolderType pFolderType)
          Returns the default folder for the specified folder type.
 OutlookFolderID getDefaultFolderId(FolderType pFolderType)
          Deprecated. Use the getDefaultFolder(FolderType) method instead.
static java.lang.String getDefaultProfileName()
          Returns the user's default profile name as specified in the Windows registry HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile.
 ExplorersCollection getExplorers()
           
 OutlookFolder getFolder(OutlookFolderID pFolderId)
          Retrieve information about an Outlook folder identified by the folder ID.
 OutlookFolder getFolder(java.lang.String folderPath)
          Returns a folder for the specified name or path.
 FoldersCollection getFolders()
          Retrieve information about Outlook folders.
 InspectorsCollection getInspectors()
           
 OutlookItem getItem(OutlookFolderID pFolderId, OutlookItemID pItemId)
          Retrieve information about an Outlook item identified by the specified item ID.
 OutlookItem getItem(OutlookItemID pItemId)
          Retrieve information about an Outlook item identified by the specified item ID.
 com.moyosoft.connector.com.Dispatch getNamespaceDispatch()
           
 java.lang.String getOutlookVersion()
           
 OutlookFolder getPersonalFolder(java.lang.String folderPath)
          Returns a sub-folder of the root "Personal folders" folder for the specified name or path.
static java.lang.String[] getProfileNames()
          Returns all the user's profiles listed in the Windows registry HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\.
 OutlookRecipient getRecipientFromID(java.lang.String entryID)
          Returns the OutlookRecipient object for the specified ID.
 RemindersCollection getReminders()
           
 java.util.List getRootFolders()
          Deprecated. Use the getFolders() method instead.
 OutlookFolder getRootPersonalFolder()
          Returns the root "Personal folders" folder.
 OutlookFolder getSharedDefaultFolder(OutlookRecipient pRecipient, FolderType pFolderType)
          Returns the specified default folder for the specified user.
 boolean isOffline()
           
 void logoff()
          Logs off
 void logon()
          Logs on with the default profile or displays a profile selection dialog box.
 void logon(java.lang.String pProfile)
          Logs on with the specified profile.
 void logon(java.lang.String pProfile, java.lang.String pPassword, boolean pShowDialog, boolean pNewSession)
          Logs on with the specified profile.
 OutlookFolder pickFolder()
           
 void quitApplication()
           
 void removeStore(OutlookFolder folder)
          Removes the specified folder's store and closes the corresponding PST file.
static void setLibraryPath(java.lang.String pFilePath)
          Sets the path to the native DLL library file (moyocore.dll).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Outlook

public Outlook()
        throws com.moyosoft.connector.com.ComponentObjectModelException,
               LibraryNotFoundException
Default constructor. Creates the Outlook object and logs on with the default profile.

Throws:
com.moyosoft.connector.com.ComponentObjectModelException
LibraryNotFoundException

Outlook

public Outlook(java.lang.String profile,
               java.lang.String password)
        throws com.moyosoft.connector.com.ComponentObjectModelException,
               LibraryNotFoundException
Creates the Outlook object and logs on with the specified profile.


Outlook

public Outlook(java.lang.String profile,
               java.lang.String password,
               boolean showDialog,
               boolean newSession)
        throws com.moyosoft.connector.com.ComponentObjectModelException,
               LibraryNotFoundException
Creates the Outlook object and logs on with the specified profile.

Method Detail

setLibraryPath

public static void setLibraryPath(java.lang.String pFilePath)
                           throws com.moyosoft.connector.com.ComponentObjectModelException
Sets the path to the native DLL library file (moyocore.dll).

If the library file is not in a location defined by the java.library.path system property, this method can be used to specify the exact location of the file.

Alternatively, the java.library.path property can be defined when launching the Java application:
java -Djava.library.path=[Folder where the library file is] ...

This static method has to be called BEFORE creating an instance of the Outlook object.

Usage example:

Outlook.setLibraryPath("c:\\moyocore.dll");
Outlook outlook = new Outlook();
//...
outlook.dispose();

Parameters:
pFilePath - the path to the native DLL file, including the filename (moyocore.dll)
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if the library is already loaded.

createInstance

public static Outlook createInstance(com.moyosoft.connector.com.ComManager comManager)
                              throws com.moyosoft.connector.com.ComponentObjectModelException,
                                     LibraryNotFoundException
Creates the Outlook object and logs on with the default profile.

Throws:
com.moyosoft.connector.com.ComponentObjectModelException
LibraryNotFoundException

createInstance

public static Outlook createInstance(com.moyosoft.connector.com.ComManager comManager,
                                     java.lang.String profile,
                                     java.lang.String password,
                                     boolean showDialog,
                                     boolean newSession)
                              throws com.moyosoft.connector.com.ComponentObjectModelException,
                                     LibraryNotFoundException
Creates the Outlook object and logs on with the specified profile.

com.moyosoft.connector.com.ComponentObjectModelException
LibraryNotFoundException

getDefaultProfileName

public static java.lang.String getDefaultProfileName()
                                              throws LibraryNotFoundException,
                                                     RegistryException
Returns the user's default profile name as specified in the Windows registry HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile.
This method is only available in the Professional edition of Java Outlook Connector.

Returns:
the user's default profile name
LibraryNotFoundException
RegistryException

getProfileNames

public static java.lang.String[] getProfileNames()
                                          throws LibraryNotFoundException,
                                                 RegistryException
Returns all the user's profiles listed in the Windows registry HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\.
This method is only available in the Professional edition of Java Outlook Connector.

Returns:
the list of all user's profiles
LibraryNotFoundException
RegistryException

logon

public void logon(java.lang.String pProfile,
                  java.lang.String pPassword,
                  boolean pShowDialog,
                  boolean pNewSession)
           throws com.moyosoft.connector.com.ComponentObjectModelException
Logs on with the specified profile.

Parameters:
pProfile - profile's name
pPassword - password
pShowDialog -
pNewSession - if true create a new session; otherwise use existing session if any
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any error occurs

logon

public void logon(java.lang.String pProfile)
           throws com.moyosoft.connector.com.ComponentObjectModelException
Logs on with the specified profile.

Parameters:
pProfile - profile's name
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any error occurs

logon

public void logon()
           throws com.moyosoft.connector.com.ComponentObjectModelException
Logs on with the default profile or displays a profile selection dialog box.

Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any error occurs

logoff

public void logoff()
            throws com.moyosoft.connector.com.ComponentObjectModelException
Logs off

Throws:
com.moyosoft.connector.com.ComponentObjectModelException

getFolders

public FoldersCollection getFolders()
                             throws com.moyosoft.connector.com.ComponentObjectModelException
Retrieve information about Outlook folders.

Returns:
the collection of OutlookFolder objects.
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if an COM error occurs.

getAllFolders

public java.util.List getAllFolders()
                             throws com.moyosoft.connector.com.ComponentObjectModelException
Deprecated. Use the getFolders() method instead.

Retrieve information about all Outlook folders.

Returns:
list of OutlookFolder objects.
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if an COM error occurs.

getRootFolders

public java.util.List getRootFolders()
                              throws com.moyosoft.connector.com.ComponentObjectModelException
Deprecated. Use the getFolders() method instead.

Retrieve information about root Outlook folders.

Returns:
list of OutlookFolder objects.
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if an COM error occurs.

getFolder

public OutlookFolder getFolder(OutlookFolderID pFolderId)
                        throws com.moyosoft.connector.com.ComponentObjectModelException
Retrieve information about an Outlook folder identified by the folder ID.

Returns:
OutlookFolder object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getDefaultFolderId

public OutlookFolderID getDefaultFolderId(FolderType pFolderType)
                                   throws com.moyosoft.connector.com.ComponentObjectModelException
Deprecated. Use the getDefaultFolder(FolderType) method instead.

Returns the default folder's ID for the specified folder type.

Parameters:
pFolderType - folder type
Returns:
OutlookFolderID object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getDefaultFolder

public OutlookFolder getDefaultFolder(FolderType pFolderType)
                               throws com.moyosoft.connector.com.ComponentObjectModelException
Returns the default folder for the specified folder type.

Parameters:
pFolderType - folder type
Returns:
OutlookFolder object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getRootPersonalFolder

public OutlookFolder getRootPersonalFolder()
Returns the root "Personal folders" folder.


getPersonalFolder

public OutlookFolder getPersonalFolder(java.lang.String folderPath)
Returns a sub-folder of the root "Personal folders" folder for the specified name or path. Accepted path separators are '\' or '/'.

Example:

Outlook outlook = new Outlook();
OutlookFolder inbox = outlook.getPersonalFolder("Inbox");
outlook.dispose();


getFolder

public OutlookFolder getFolder(java.lang.String folderPath)
                        throws com.moyosoft.connector.com.ComponentObjectModelException
Returns a folder for the specified name or path. Accepted path separators are '\' or '/'.

Example:

Outlook outlook = new Outlook();
OutlookFolder inbox = outlook.getFolder("Personal folders\\Inbox");
OutlookFolder myPublicFolder = outlook.getFolder("Public Folders/All Public Folders/My folder");
outlook.dispose();

com.moyosoft.connector.com.ComponentObjectModelException

getItem

public OutlookItem getItem(OutlookFolderID pFolderId,
                           OutlookItemID pItemId)
                    throws com.moyosoft.connector.com.ComponentObjectModelException
Retrieve information about an Outlook item identified by the specified item ID. This item is searched in the specified folder.

Returns:
OutlookItem object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getItem

public OutlookItem getItem(OutlookItemID pItemId)
                    throws com.moyosoft.connector.com.ComponentObjectModelException
Retrieve information about an Outlook item identified by the specified item ID.

Returns:
OutlookItem object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getCurrentUser

public OutlookRecipient getCurrentUser()
                                throws com.moyosoft.connector.com.ComponentObjectModelException
Returns the currently logged-on user as an OutlookRecipient object

Returns:
OutlookRecipient object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

createRecipient

public OutlookRecipient createRecipient(java.lang.String pRecipientName)
                                 throws com.moyosoft.connector.com.ComponentObjectModelException
Create a recipient object. This method is most commonly used to create a Recipient object for use with the getSharedDefaultFolder method, for example, to open a delegator's folder. It can also be used to verify a given name against an address book.

Parameters:
pRecipientName - The name of the recipient; it can be a string representing the display name, the alias, or the full SMTP e-mail address of the recipient.
Returns:
OutlookRecipient object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getSharedDefaultFolder

public OutlookFolder getSharedDefaultFolder(OutlookRecipient pRecipient,
                                            FolderType pFolderType)
                                     throws com.moyosoft.connector.com.ComponentObjectModelException
Returns the specified default folder for the specified user. This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar folder).

Returns:
OutlookFolder object
Throws:
com.moyosoft.connector.com.ComponentObjectModelException - if any COM error occurs.

getOutlookVersion

public java.lang.String getOutlookVersion()

getActiveExplorer

public Explorer getActiveExplorer()
Returns the active (focused) Outlook Explorer window. The Explorer is the main window listing Outlook folders.


getActiveInspector

public Inspector getActiveInspector()
Returns the active (focused) Outlook Inspector window. The Inspector is the item's window, like an e-mail or contact window.


quitApplication

public void quitApplication()

getExplorers

public ExplorersCollection getExplorers()

getInspectors

public InspectorsCollection getInspectors()

getActiveWindow

public OutlookWindow getActiveWindow()

getReminders

public RemindersCollection getReminders()

getAddressLists

public AddressListsCollection getAddressLists()

pickFolder

public OutlookFolder pickFolder()

addStore

public void addStore(java.io.File storePstFile)
Opens the specified PST file in a new Outlook folder. To remove the added folder, use the method removeStore. If the specified file doesn't exist, a new PST file will be created.

Parameters:
storePstFile - the PST file to be loaded
See Also:
removeStore(OutlookFolder)

addStore

public void addStore(java.io.File storePstFile,
                     StoreType type)
Opens the specified PST file in a new Outlook folder. To remove the added folder, use the method removeStore. If the specified file doesn't exist, a new PST file will be created using the specified store type.

Parameters:
storePstFile - the PST file to be loaded
type - the type of the store: StoreType.DEFAULT, StoreType.UNICODE or StoreType.ANSI
See Also:
removeStore(OutlookFolder)

removeStore

public void removeStore(OutlookFolder folder)
Removes the specified folder's store and closes the corresponding PST file. Used after a store has been added with the method addStore(File).

See Also:
addStore(File)

isOffline

public boolean isOffline()

dial

public void dial()

dial

public void dial(OutlookContact contactToDial)

getAccounts

public AccountsCollection getAccounts()
Returns the Outlook accounts collection. The accounts are only supported by Outlook 2007 or later; with other versions this method will throw an ComponentObjectModelException.
This method is only available in the Professional edition of Java Outlook Connector.


createItemFromTemplate

public OutlookItem createItemFromTemplate(java.io.File templateFile)
Creates an OutlookItem object from the specified .msg file.


createItemFromTemplate

public OutlookItem createItemFromTemplate(java.io.File templateFile,
                                          OutlookFolder destinationFolder)
Creates an OutlookItem object from the specified .msg file and places that item in the specified destination folder.


getRecipientFromID

public OutlookRecipient getRecipientFromID(java.lang.String entryID)
Returns the OutlookRecipient object for the specified ID. The ID of a recipient is returned by the method OutlookRecipient.getEntryId().


getApplicationDispatch

public com.moyosoft.connector.com.Dispatch getApplicationDispatch()

getNamespaceDispatch

public com.moyosoft.connector.com.Dispatch getNamespaceDispatch()

dispose

public void dispose()
Dispose the outlook library.