A WebDAV Sample: Creating Tasks
To show you how to use WebDAV in a little more detail, the following code creates a task programmatically using WebDAV. (See Figure 16-8.) To learn how to create, modify, or delete a contact using WebDAV, see the Microsoft Knowledge Base article 296126.
Figure 16-8: Creating a task item via WebDAV and XMLHTTP
strPropSet = "<?xml version='1.0'?>" _
& "<d:propertyupdate xmlns:d='DAV:' " _
& "xmlns:e='http://schemas.microsoft.com/exchange/' " _
& "xmlns:b='urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/' " _
& "xmlns:f='urn:schemas:mailheader:' " _
& "xmlns:g='urn:schemas:httpmail:' " _
& "xmlns:h='http://schemas.microsoft.com/mapi/id/" _
& "{00062003-0000-0000-C000-000000000046}/'><d:set><d:prop>" _
& "<d:contentclass>urn:content-classes:task</d:contentclass>" _
& "<e:outlookmessageclass>IPM.Task</e:outlookmessageclass>" _
& "<f:subject>This is a test-task</f:subject>" _
& "<g:textdescription>Body-Text goes here</g:textdescription>" _
& "<h:0x00008102 b:dt='float'>.25</h:0x00008102>" _
& "<h:0x00008101 b:dt='int'>1</h:0x00008101>" _
& "</d:prop></d:set></d:propertyupdate>"
'8102 is % Task Complete
'8101 is Task Status - Not started, In progress, etc.
With New XMLHTTP
strURL = "http://server/Exchange/user/tasks/testtask.eml"
.open "PROPPATCH", strURL, False, "username", "userpassword"
.setRequestHeader "Content-Type:", "text/xml"
.setRequestHeader "Translate", "f"
.send strPropSet
If Not (.Status >= 200 And .Status < 300) Then
MsgBox .Status & " " & .statusText
End If
End With