Topic : Accessing MS Exchange Server using WebDAV
Tools : C#, MSXML, ASP.Net... and lil bit of grey matter! ;)
As a Developer, we, have to face many scenarios... sometimes it is easy to get things goin...
while sometimes... you fell why did you raise your hand to solve that particular thing.
Same thing happenned to me, few days back, I was trying to access MS Exchange 2000 to
get mails from a given mailbox, and extract mails from it. I already did it using a Pop3 Class
I got from CodeProject.com. but than the question was accessing RAW mail ie .eml or .msg
so I had to forget 2-3 days I spent to get Pop3 working with the Current System. After
looking for some help here and there, I came to know about WebDAV - Web(-based)
Distributed Authoring & Versioning. After doin R&D I felt that this is the thing that I was
looking for... so I started DEVENV and loaded my R&D Project(I call it.. WebCentrino... he he)
Here are the steps that will get you a mail in RAW format from MS Exchange Server.
1. Creat a New Web Application (you can go for WinApp also)
2. Add reference to MS XML 4.0 or greater, it will appear as MSXML2 in References
3. Now, add this System.IO, System.Xml and System.MSXML2
4. Add following code to the Page_Load event. This dumps XML Listing of your mail box. You'll have to write a Custom Handler to process the Output and display to User.
WebRequest.open("PROPFIND", "http://mail.urmailserver.com/exchange/username/inbox", false, "domain\\username", "password");//Connect to the Mail Server
WebRequest.setRequestHeader("Depth", "1");//Set Access Depth
WebRequest.setRequestHeader("Content-type", "xml");//Set Content Type of the Request
WebRequest.send(null);//Send the Request
Response.Write(WebRequest.responseText);//Dump Response from the Server
This will get you mailbox content with all the attirbutes you'll ever need to access your mailbox.
if you need more on this look into MSDN and MS Exchange Online Docs.
Comments/Suggestions on this article are most welcome.