JEC/EWSJ provides a java connector to exchange server. With it you can write java code that accesses and manipulates calendar, contacts, tasks, emails, send meeting requests and accept meeting requests in exchange server. Basically JEC and EWSJ have the same feature set, the difference is that JEC uses the WebDAV interface and EWSJ uses the Web Services interface, which makes the last more suitable to exchange 2007 server. In case you have both WebDav and EWS interfaces open, you'll need to evaluate both products to see which one is better suited to your needs. Our recommendation is to use EWSJ for 2007 and JEC for 2000 and 2003.
Here are some basic Examples, for the full examples look at ExchangeConnectorExamples.java and EWSJExamples.java in the example directory of the evaluation download.
Expand EWSJ distribution to a file system location without spaces. Include ewsj.jar (in the bin directory) and all the jars in the lib directory in the CLASSPATH, you should also include the lib directory itself in the CLASSPATH (this enables EWSJ find the license file and more configuration files).
To successful connect to Exchange via the EWS interface you will need to know this parameters:
1. Username: your Exchange username.
2. Password: your Exchange password.
3. AccountName: The account you want to connect to (in most cases its the same as your user name, except in case of impersonation or mailbox sharing, see related user-guide).
4. Domain: your domain name.
5. useSSL: Boolean that indicates if you use secure connection.
6. Prefix: Always "Exchange".
You can test if your Exchange EWS interface is open via this URL:
http(s)://<exchange_host>/ews/Exchange.asmx
If you get a valid response (xml response), then its OK you have EWS Interface open, if not, contact your Exchange Administrator to open the EWS interface.
After you have the above information you can connect to Exchange using this lines of code:
EWSConnectorFactory factory = new EWSConnectorFactory();
EWSConnectorInterface connector = null;
connector = factory.createEWSConnector(_exchangeHost, _userName, _password, _prefix, _useSSL, _accountName);
ArrayList contacts = connector.getContacts();
If you still have problems to connect to Exchange, please see: EWSJ Connection problems User-Guide.
You can quickly create EWSJ eclipse project using this user guide: Define EWSJ Examples Eclipse project