RE: Howto access Exchange over WebDav?
- From: Bernhard Reiter <BernhardReiter@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Apr 2005 02:38:07 -0700
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
.
- References:
- Howto access Exchange over WebDav?
- From: Johann
- RE: Howto access Exchange over WebDav?
- From: Bernhard Reiter
- RE: Howto access Exchange over WebDav?
- From: Johann
- Howto access Exchange over WebDav?
- Prev by Date: hidden a event in contacts
- Next by Date: RE: Howto access Exchange over WebDav?
- Previous by thread: RE: Howto access Exchange over WebDav?
- Next by thread: Re: Howto access Exchange over WebDav?
- Index(es):
Relevant Pages
|