Wednesday, May 2, 2012

Exchange Web Services (EWS) using PL/SQL


Since last week I've had the itch to build a PL/SQL package that interfaces with EWS (Exchange Web Services) so that I can write an inbox monitor that will conduct some sort of business upon receiving an email with a keyword etc.

So, last week I searched the web for any types of building blocks to use in this endeavor. I came up with various remnants of Oracle users attempting to contact EWS but the articles were few and far between and of little use. Worse, Microsoft's attempt at API documentation is far from Google's API doc standards.

In the end, I simply used the various tidbits I could find on the web to piece together what I have provided here. Mostly because I didn't want you, the next developer, to have to go through all I did just to get some samples up and running. The code I provide was tested on Exchange 2007.

This package was thrown together rather quickly, and only scratches the surface of the things you can do with EWS, but works as a base. You will likely wonder why I did some things the way I did. I'll likely do the same over the next couple of weeks BUT, the key thing is that i'm providing this package so that you can get started NOW, not wait, and most importantly not have to piece together your own package if you don't have the time/don't want to wait.

Please feel free to use as much as you like, ripping out and replacing content with your own! No need for comments; I know I could've done things better :).

This package in it's raw form, and oh yes it's raw, allows you to:

Use Autodiscover to determine your Exchange's correct WS endpoint.
Send an email.
Check an inbox (yours or a delegated inbox) for new emails.
Get the details of an item.
Move an item.

Note: Oddly enough, no sooner had I decided to put this package on the 'net than Mr. Braten over @ this blog decided to do the exact same thing on May 1st! (Though as of this writing has not released his code)

I think i'm going to sweep my office for bugs ;).

6 comments:

  1. Great,
    I've been struggling to use EWS with Talend Open Studio with no avail. I have tested EWS with soapUI so I know I can retrieve and post data into Exchange, but really I had to modify the wsdl file provided coz it missed the service part that I had to add manually.
    Hopefully I will be able to use your package.
    I'll report back...
    Thanks.


    Thierry Yen-Suin
    Mauritius

    ReplyDelete
  2. I am having a bear of a time trying to locate the NTLM_UTIL_PKG pl/sql package. It seems to have been removed from the Alexandria Utility Library for PL/SQL (mentioned but no links).

    Does anyone know if there is another source (no pun intended) for this?

    Thanks!

    ReplyDelete
  3. Robert, I still see the NTLM stuff in the library...

    ReplyDelete
  4. Found it. Thanks, Steve. I took a second look.

    ReplyDelete
  5. Have anybody met NTLM authorization issues using this package? I get a following message: "NTLM auth string could not be obtained". Does it depend on Exchange server I'm trying to access? Any help would be appreciated.

    ReplyDelete
  6. Great Article it its really informative and innovative keep here: with new updates. Its was really valuable. Thanks a lot. SEO for Small Business

    ReplyDelete