Microsoft Knowledge Base Email Alertz

(300185) - In Exchange 2000 you can get and set properties by using Web Distributed Authoring and Versioning (WebDAV). This article provides a Visual Basic example of how to use the WebDAV PROPFIND and PROPPATCH commands to get and set a property on a public...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 300185 - Last Review: October 19, 2009 - Revision: 4.0

How To Get and Set a Property on a Public Folder Item Using WebDAV

This article was previously published under Q300185

SUMMARY

In Microsoft Exchange 2000 Server, you can get and set properties by using Web Distributed Authoring and Versioning (WebDAV). This article provides a Visual Basic example of how to use the WebDAV PROPFIND and PROPPATCH commands to get and set a property on a public folder item.

MORE INFORMATION

To get and set the subject of an item in a public folder, follow these steps:
  1. In Exchange 2000 Server, under All Public Folders, create a public folder and name it Folder1. In Folder1, create an item and name it Test1.
  2. In Visual Basic, create a Standard EXE project. Form1 is created by default.
  3. Add a command button to Form1 and name it Command1.
  4. Add a reference to the Microsoft XML Object Library.
  5. Paste the following code in the code section of Form1.
    Note Change e2kServer in the code to the name of your Exchange server. Also, change the UserID and password that are mentioned in the "TO DO" comments to correspond to the appropriate user.
    Private Sub Command1_Click()
    sSourceURL = "http://e2kServer/public/Folder1/Test1.eml"
    
    sUserID = "Domain\UserID" 'TO DO Change the UserID.
    sPassword = "Password"  'TO DO Change the Password.
    sSubject = PropFind(sSourceURL, sUserID, sPassword)
    MsgBox sSubject
    
    'To change the subject, uncomment the following line.
    'PropPatch sSourceURL, "NewSubject"
    End Sub
    
    Function PropFind(ByVal sSourceURL As String, ByVal sUserID As String, ByVal sPassword As String) As String
    
    Dim sReq As String
    
    'TO use MSXML 2.0 use the following DIM/SET statements
    Dim XMLreq As XMLHTTP
    Set XMLreq = CreateObject("Microsoft.xmlhttp")
    Set oDocBack = CreateObject("MICROSOFT.XMLDOM")
       
    
    'To use MSXML 6.0 use the folloiwing DIM/SET statements 
    'Dim XMLreq As MSXML2.XMLHTTP60
    'Set XMLreq = CreateObject("Msxml2.XMLHTTP.6.0")
    'Set oDocBack = CreateObject("MSXML2.DomDocument.6.0")
    
    XMLreq.open "PROPFIND", sSourceURL, False, sUserID, sPassword
    
    'Set the header.
    XMLreq.setRequestHeader "Content-Type", "text/xml"
       
    sReq = "<?xml version='1.0'?>"
    sReq = sReq & "<d:propfind xmlns:d='DAV:' xmlns:m='urn:schemas:mailheader:'><d:prop>"
    sReq = sReq & "<m:subject/>"
    sReq = sReq & "</d:prop></d:propfind>"
    
    XMLreq.send sReq
    
    Set oDocBack = XMLreq.responseXML
    Set objNodeList = oDocBack.getElementsByTagName("d:subject")
    PropFind = objNodeList(0).Text
    
    End Function
    
    Sub PropPatch(ByVal sSourceURL As String, ByVal sNewVal As String)
    
    Dim sReq As String
    
    'TO use MSXML 2.0 use the following DIM/SET statements
    Dim XMLreq As XMLHTTP
    Set XMLreq = CreateObject("Microsoft.xmlhttp")
    
    
    'To use MSXML 6.0 use the folloiwing SET/DIM statements 
    'Dim XMLreq As MSXML2.XMLHTTP60
    'Set XMLreq = CreateObject("Msxml2.XMLHTTP.6.0")
    
    
       
    XMLreq.open "PROPPATCH", sSourceURL, False, sUserID, sPassword
    
    'Set the header.
    XMLreq.setRequestHeader "Content-Type", "text/xml"
    
    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>" & sNewVal & "</m:subject>"
    sReq = sReq & "</d:prop></d:set></d:propertyupdate>"
     
    XMLreq.send sReq
    
    If XMLreq.Status = 207 Then
        MsgBox "Success"
    End If
    
    End Sub
    					
  6. Run the project.

REFERENCES

For more information about WebDAV, see the WebDAV book in the Exchange SDK, and the WebDAV Sample Application in the "Solutions" section of the Exchange SDK, located at the following Web site:
http://msdn2.microsoft.com/en-us/exchange/default.aspx (http://msdn2.microsoft.com/en-us/exchange/default.aspx)

APPLIES TO
  • Microsoft Exchange 2000 Server Standard Edition
  • Microsoft XML Parser 2.0
  • Microsoft XML Parser 2.5
  • Microsoft XML Parser 2.6
  • Microsoft XML Parser 3.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft XML Core Services 6.0
Keywords: 
kbhowto kbmsg KB300185
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate