Microsoft KB Archive/310289

= How to copy or move a message from one folder to another folder on a computer that is running Exchange 2000 Server by using Visual C# =

Article ID: 310289

Article Last Modified on 12/11/2006

-

APPLIES TO


 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft XML Core Services 4.0
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# 2005

-



This article was previously published under Q310289



SUMMARY
This article describes how to use Microsoft XML 3.0 to copy or to move a message from one folder to another folder on a computer that is running Microsoft Exchange 2000 Server by using Visual C#.



MORE INFORMATION
To copy or to move a message from one folder to another folder on a computer that is running Exchange 2000, follow these steps:  Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, point to New, and then click Project. In the Visual C# Projects types list, click Console Application.

Note In Visual Studio 2005, click Console Application in the Visual C# list.

In Visual Studio .NET, Class1.cs is created by default. In Visual Studio 2005, Program.cs is created by default. Add a reference to Microsoft XML 3.0. To do so, follow these steps:  On the Project menu, click Add Reference. Click the COM tab, locate Microsoft XML v3.0, and then click Select.

Note In Visual Studio 2005, you do not have to click Select. In the Add References dialog box, click OK.</li> If you are prompted to generate wrappers for the libraries that you selected, click Yes .</li></ol> </li>  In the code window, replace the code with the following: using System; using System.Reflection;

namespace WebDav {  class Class1 {        public static void Main(String [] args) {        try {           MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30;

//TODO : Replace with source URL and the destination URL. String sSourceURL = &quot;http://ExchServer/Public/MyFolder1/Test.eml&quot;; String sDestinationURL = &quot;http://ExchServer/Public/MyFolder2/Test.eml&quot;;

// COPY // TODO: Replace the credentials oXMLHttp.open(&quot;COPY&quot;, sSourceURL, false, @&quot;UserDomain\UserAlias&quot;, &quot;UserPassword&quot;);

// MOVE // TODO: Replace the credentials //oXMLHttp.open(&quot;MOVE&quot;, sSourceURL, false, @&quot;UserDomain\UserAlias&quot;, &quot;UserPassword&quot;);

oXMLHttp.setRequestHeader(&quot;Destination&quot;, sDestinationURL); oXMLHttp.send(Missing.Value);

Console.WriteLine(oXMLHttp.status); Console.WriteLine(oXMLHttp.statusText); Console.WriteLine(oXMLHttp.responseText); oXMLHttp = null; }        catch (Exception e)         { Console.WriteLine(&quot;{0} Exception caught.&quot;, e); }     }   } } </li> Search for TODO in the code, and then modify the code for your environment.</li> Press F5 to build and to run the program.</li> Make sure that the message has been copied or moved.</li></ol>

Additional query words: copy move items WebDAV Exchagne Server

Keywords: kbxml kbhowto kbmsg KB310289

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.