17 Jul 2008

Outlook interfacing - An alternate way

Sometimes, even after spending half a decade in the IT field you'll keep encountering interesting technologies that either you didn't know of or didn't care to take seriously. At times, these can neverthless provide some really nifty solutions. It was recently that I got enlightened on one of these. Not that I hadn't heard of it before - but never gave it a second glance.

The problem was a typical one. An automation component I was into - needed to fetch attachments from a designated mailbox according to a mail pattern, download them & initiate a processing batch for the downloaded ones. It was supposed to be run as a scheduled task.

Now, its a simple problem - especially if you have Visual Studio .NET installed and know a bit or so about writing C# code & using the Outlook Object Library. So I rightway started off & had almost got to fetching the mail object & reading the sender name - when I hit a wall ! Outlook complained with a popup saying "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this?". Someone had to approve or deny this request!

That meant my automation component would sit there waiting for someone to approve/deny its access to my mailbox. This was bad for me (Though it was bound to happen as I'd been on the Java side for long & hadn't been in touch with Outlook security model and such). It seems, in view of the proliferating virus scene, Microsoft decided to add this security check whenever some process accesses the Outlook address book. Also there seemed no easy way to skip this one (unless you downloaded some third-party libraries for getting around this limitation. In my scenario that just wasn't possible.)

Some may say - why not use a simple mail rule in outlook, connect it to some VBScript to download the attachments for the target mail items as soon as they arrive. That would be great but then corporate security forbids us from tinkering around with the outlook client. No programmatic extensions, no macros, no scripts running in Outlook !. I was about to give up when one of my last google searches threw up an interesting link "Access outlook using WebDAV". I had heard of WebDAV before. Most ECM systems provide a WebDAV interface for accessing content. But what was this strange connection between Outlook & WebDAV ? Intrigued, I checked on further.

That was how I realised that Outlook is accessible via WebDAV too. Infact that is the underlying access mechanism behind the Microsoft OWA(Outlook Web Access) client. Also, most corporate systems donot disable the WebDAV access as it's essential for proper functioning of Outlook.

I got some nice details here, some excellent samples and advice here & here, then set about the task & finally came up with a simple mail attachment download utility in javascript. Added a functional web interface to it, wrapped it up as an HTA application, configured it to run on schedule, did some 5 - 6 rounds of testing, skipped the documentation for later & patted myself for a job well done ;-).

No comments :

Post a Comment