Microsoft Knowledge Base Email Alertz

This article demonstrates how to move or copy folder items by using Web Distributed Authoring and Versioning (WebDAV) and Microsoft Visual Basic (VB).

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: 290111 - Last Review: February 22, 2007 - Revision: 2.5

How To Move or Copy Folder Items with WebDAV

This article was previously published under Q290111

SUMMARY

This article demonstrates how to move or copy folder items by using Web Distributed Authoring and Versioning (WebDAV) and Microsoft Visual Basic (VB).

MORE INFORMATION

A typical move or copy request resembles the following:
Move SourceURL
Destination DestinationURL
				
The following sample demonstrates how to move or copy an item, Test1, from Folder1 to Folder2.

NOTE: You can only copy or move objects within the same store.
  1. In Exchange 2000 Server, under All Public Folders, create two public folders and name them Folder1 and Folder2. In Folder1, create an item and name it Test1.
  2. In VB, 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 MSXML 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.
    Private Sub Command1_Click()
    sSourceURL = "http://e2kServer/Public/Folder1/Test1.eml" 'TO DO
    sDestinationURL = "http://e2kServer/Public/Folder2/Test1.eml" 'TO DO
    'CopyMoveUsingWebDav sSourceURL, sDestinationURL, True 'To Copy
        CopyMoveUsingWebDav sSourceURL, sDestinationURL, False 'To MoveEnd Sub
    
    Sub CopyMoveUsingWebDav(ByVal sSourceURL As String, ByVal sDestinationURL As String, ByVal bCopy As Boolean)
    ' dim for xml 2.0
    'Dim XMLreq As MSXML.XMLHTTPRequest
    ' dim for xml 4.0
    Dim XMLreg As MSXML2.XMLHTTP
    Dim sReq As String
     
    
    'Use XML to create the new folder.
    Set XMLreq = CreateObject("Microsoft.xmlhttp")
    If bCopy Then
        XMLreq.open "COPY", sSourceURL, False
    Else
        XMLreq.open "MOVE", sSourceURL, False
    End If
    XMLreq.setRequestHeader "Destination", sDestinationURL
    
    'Send the request to set the search criteria.
    XMLreq.send
    'Display the results.
    If (XMLreq.Status >= 200 And XMLreq.Status < 300) Then
      Debug.Print "Success!   " & "Results = " & XMLreq.Status & ": " & XMLreq.statusText
    ElseIf XMLreq.Status = 401 then
      Debug.Print "You don't have permission to do the job! Please check your permissions on this item."
    Else
      Debug.Print "Request Failed.  Results = " & XMLreq.Status & ": " & XMLreq.statusText
    End If
    
    End Sub
    					
  6. Run the project.NOTE: If you run the code to move Test1 (bCopy = false), make sure that you have at least Editor permissions in Exchange on Test1.

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

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