Howto: WebDAV PROPFIND using VBScript



'The example below demonstrates how to do a WebDAV PROPFIND.  


Note: PROPFINDs are non-conditional.  Use a SEARCH for reading properties conditionally.


dim sHREF
dim sUserName 
dim sPassword 
dim sResponse 
Dim HttpWebRequest
dim sReq ' Body Proppatch statement


sHREF = "https://myexserver/exchange/Administrator/Inbox/testabcd.EML"  ' TODO: change
‘ If only the folder is specified, all items will have a PROPFIND done on them
‘sHREF = "http://myexserver/exchange/administrator/Inbox/"  ' TODO: change
sUserName = "Administrator"    ' TODO: change
sPassword = "test"    ' TODO: change


set HttpWebRequest = CreateObject("microsoft.xmlhttp")
 
'Set HttpWebRequest = New Msxml2.XMLHTTP30
HttpWebRequest.Open "PROPFIND", sHREF, False, sUserName, sPassword 
HttpWebRequest.setRequestHeader "Content-Type", "text/xml"
'HttpWebRequest.setRequestHeader "Depth:","0"
HttpWebRequest.setRequestHeader "Depth:","1"


sReq = ""
sReq = "<?xml version='1.0'?>"
sReq = sReq & "<d:propertyupdate xmlns:d='DAV:' xmlns:m='urn:schemas:mailheader:'>"
sReq = sReq & "<d:set><d:prop>"
sReq = sReq & "<m:subject>" & "test1" & "</m:subject>"
sReq = sReq & "</d:prop></d:set></d:propertyupdate>"


sReq = "<?xml version='1.0'?>" & _
         "<a:propfind xmlns:a='DAV:' xmlns:m='urn:schemas:mailheader:' xmlns:n='urn:schemas:httpmail:'>" & _
         "<a:prop>" & _
         "<m:subject/>" & _
         "<m:to/>" & _
         "<m:from/>" & _
         "<m:cc/>" & _
         "<m:bcc/>" & _
         "<n:date/>" & _
         "<n:datereceived/>" & _
         "<n:importance/>" & _
         "<n:textdescription/>" & _
         "<n:htmldescription/>" & _
         "<a:isfolder/>" & _
         "<a:displayname/>" & _
         "<a:href/>" & _
         "</a:prop>" & _
         "</a:propfind>"
 
HttpWebRequest.Send sReq


sResponse  = HttpWebRequest.ResponseText  ' Returns as text
'ReadAnAttatchment = HttpWebRequest.responseBody ' Returns as encoded


wscript.echo sResponse 
   
Set HttpWebRequest = Nothing

Comments (1)

  1. Rajesh says:

    U saved my day Daniel. I was trying to find this solution for 3 days. Fianlly got ur post. Thanks alot.

Skip to main content