RE: Howto access Exchange over WebDav?



Here comes the sample... ;)

*
* Sample for get appointments from an Exchange Server using WebDAV
* Modified sample from MSDN Site, with extended SQL Query String
*

lcUSerName = "UserTest"
lcServer = "myExchangeServer"
lcPassword = "PASSWORD"

* Set the Serverpath - Notice ! If your'e using US/EN ExchangeServer change
Kalender into Calendar
* otherwise let it be Kalendar, but this is only usable for German Exchange
Servers
lcServerPAth = "http://"; + lcServer + "/exchange/" + lcUserName + "/Kalender/"

* Create XML Parser Objects
reqDoc = CreateObject("microsoft.xmldom")
resDoc = CreateObject("microsoft.xmldom")

* Create XML 1.0 Documents
proI = reqDoc.createProcessingInstruction("xml","version='1.0'")
reqDoc.appendChild (proI)

* We would do a search on the Exchange using DAV: (WebDAV)
searchrequestNode = reqDoc.createNode(1,"searchrequest","DAV:")
reqDoc.documentElement = searchrequestNode

* Create XML SQL WebDAV Node
sqlNode =reqDoc.createNode(1,"sql","DAV:")
searchrequestNode.appendChild(sqlNode)

* Now put together the Querystring for WebDav, here we've to specify what we
would use in our Application
* urn:schemas:calendar:location : Location of the app/meeting (string)
* urn:schemas:calendar:alldayevent : Is it allday event ? (boolean)
* urn:schemas:httpmail:textdescription : App/Meeting description
* urn:schemas:calendar:reminderoffset : Remindertime in minutes (integer)
* urn:schemas:calendar:dtstamp : When was the app/meeting created or last
modified ? (dateTime)
* dateTime format "YYYY/MM/DD HH/MM/SS"
* urn:schemas:httpmail:subject : Subject of the appointment (string)
* urn:schemas:calendar:busystatus : Busy or not Busy (string / BUSY or FREE)
* urn:schemas:calendar:dtstart : Appointment start (dateTime)
* urn:schemas:calendar:dtend : Appointment end (dateTime)
* urn:schemas:calendar:instancetype : Recurring or singel appointment
(integer/ 0 = Single)

strQuery = [Select "urn:schemas:calendar:location",
"urn:schemas:calendar:alldayevent",]
strQuery = strQuery +
["urn:schemas:httpmail:textdescription","urn:schemas:calendar:reminderoffset",]
strQuery = strQuery +
["urn:schemas:calendar:dtstamp","urn:schemas:httpmail:subject",]
strQuery = strQuery + ["urn:schemas:calendar:busystatus",
"urn:schemas:calendar:dtstart",]
strQuery = strQuery +
["urn:schemas:calendar:dtend","urn:schemas:calendar:instancetype" ]
strQuery = strQuery + [FROM Scope('SHALLOW TRAVERSAL OF "]

* Select only Appointments (contentclass:appointment) from our Ex.Server
strQuery = strQuery + [] + lcServerPath +["') WHERE "DAV:contentclass"=
'urn:content-classes:appointment']

* Heres the Date range, from what Time we would like to get appointments,
here in this sample
* the time from 24th April 2005 till 28th April 2005
strQuery = strQuery + [ AND "urn:schemas:calendar:dtstart" > '2005/04/24
00:00:00' AND "urn:schemas:calendar:dtend" < '2005/04/28 00:00:00']

* And sorted by Time, means the last appointment appears at the end of the
returned XML String
strQuery = strQuery + [ ORDER BY "urn:schemas:calendar:dtstart" ASC ]

* Create the QueryNode
queryNode = reqDoc.createTextNode(strQuery)
sqlNode.appendChild (queryNode)

* Create the XML HTTP Object to get back the XML Results
req = CreateObject("msxml2.xmlhttp")

* AND here the WebDAV Command Search, behind USername and Password- you need
rights to access the calendar !
req.open ("SEARCH",lcServerPath,.f.,lcUserName,lcPassword)
* Specify the Content Type which we send to the server
req.setRequestHeader("Content-Type","text/xml")
* And send out to Exchange Server..
req.send (reqDoc)

* Get the response from out Exchange Server..
resDoc = req.responseXML

* Now split up all Nodes...
objSubjectNodeList = resDoc.getElementsByTagName("e:subject")
objLocationNodeList = resDoc.getElementsByTagName("d:location")
objStartTimeNodeList = resDoc.getElementsByTagName("d:dtstart")
objEndTimeNodeList = resDoc.getElementsByTagName ("d:dtend")
objBusyStatusNodeList = resDoc.getElementsByTagName("d:busystatus")
objInstanceTypeNodeList = resDoc.getElementsByTagName("d:instancetype")
objAllDayNodeList = resDoc.getElementsByTagName("d:alldayevent")
objDescriptionNodeList = resDoc.getElementsByTagName("e:textdescription")
objRemNodeList = resDoc.getElementsByTagName("d:reminderoffset")
objStatusList = resDoc.getElementsByTagName("d:busystatus")
objContact = resDoc.getElementsByTagName("d:attendeestatus")
objTS = resDoc.getElementsByTagName("d:dtstamp")

* Get each Node
For i = 0 to (objSubjectNodeList.length -1)
* Determine each element
loSubject = objSubjectNodeList.nextNode
loLocation = objLocationNodeList.nextNode
loStart = objStartTimeNodeList.nextNode
loEnd = objEndTimeNodeList.nextNode
loAllDay = objAllDayNodeList.nextNode
loDesc = objDescriptionNodeList.nextNode
loRemind = objRemNodeList.nextNode
loBusy = objStatusList.nextNode
loTS = objTS.nextNode

* And now show it on our console in FoxPro
? 'Subject ' + loSubject.text
? 'Location ' + loLocation.text
? 'Busystatus ' + loBusy.text
? 'App. start ' + loStart.text
? 'App. ende ' + loEnd.text
? 'Alldayevent ? ' + loAllDay.text
? 'Reminder ' + (Val(loRemind.text) / 60) + ' minutes'
? 'Timestamp ' + loTs.text
Endfor

.



Relevant Pages

  • Re: WebDAV disabled!
    ... I got one more Query, ... WebDAV service extension is enabled in Exchange Server 2003, ...
    (microsoft.public.exchange.admin)
  • Re: Read inboxes of various mailboxes on Exchange Server
    ... Here is a list of of the WebDAV scheme used by exchange: ... To get the attachments, you must use the propietary X-MS-ENUMATTS method ... > at sending a query to our Exchange Server to return back data I needed. ... >> In this case do a PROPFIND on the mailbox root and retrieve the property ...
    (microsoft.public.exchange2000.development)
  • Re: WebDAV disabled!
    ... but the Web Service Extension named WebDAV is nothing to do with OWA - ... that extension enables WebDAV on the entire server, ... Look at the properties of the Microsoft Exchange Server ...
    (microsoft.public.exchange.admin)
  • Re: Detect Undeliverable Email using WebDAV?
    ... MAPI can only be used within the Exchange server. ... email addresses are undeliverable, using WebDAV. ... for each objattachment in objattachments ... I saw the discussion about "Detect Undeliverable Email using WebDAV" by ...
    (microsoft.public.exchange2000.development)
  • Conflict Message
    ... logging on with outlook profiles created on the fly. ... does not edit appointments in Outlook, he only edits them in the CRM ... engine was logged onto exchange server under the same profile. ...
    (microsoft.public.exchange.development)