Copying Public Folders Using ADO

Copying Public Folders Using ADO

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

VBScript

Note  The following example uses a file URL with the Exchange OLE DB (ExOLEDB) provider. The ExOLEDB provider also supports The HTTP: URL Scheme. Using The HTTP: URL Scheme allows both client and server applications to use a single URL scheme.

'Copying Public Folders Using ADO
-->

<!--
'Build Instructions
' Add the following Active Server Pages (ASP) file to a new virtual directory under the wwwroot.
' Change the domain in the code to reflect your install.
' Make sure that there are public folders in the Public Folder tree with the same names as listed in
' the code.
-->

<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim Rec
Dim strURL

Dim DomainName
Dim strLocalPath
Dim strDestination

const for the ADO CopyRecord method
const adCopyOverWrite = 1
const adCopyNonRecursive = 2

' Specify your own domain.
DomainName = "mydomain.contoso.com"

' Specify a URL to the folder or the items to copy.
' In this example, a folder and its items are copied.

strLocalPath = "PUBLIC FOLDERS/ProjectTrack"
strDestination = "PUBLIC FOLDERS/myfolder"

Set Rec = CreateObject("ADODB.Record")

' Set the strURL to the location of the folders.
strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath
strDest = "file://./backofficestorage/" & DomainName & "/" & strDestination

' Open the record.
Rec.Open strURL

' Copy the folder from the source location to the destination folder.
' Note that if an item already exists at the destination URI,
' it will be overwritten by the copy.
 Rec.CopyRecord strURL,"file://./backofficestorage/" & DomainName _
   & "/" & strDestination,,,adCopyOverWrite

' Close the record.
Rec.Close
Set Rec = Nothing

Response.write "adCopyOverWrite: " & adCopyOverWrite & "<BR>"
Response.write "adCopyNonRecursive: " & adCopyNonRecursive & "<BR>"
Response.write "strURL: " & strURL & "<BR>"
Response.write "strDest: " & strDest & "<BR>"
Response.Write "<BR><BR>All Done" & "<BR>"
%>
</BODY>
</HTML>
<!--

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.