Home   |   Asp.Net 2.0   |   .Net Framework 2.0   |   IIS 6.0   |   Sql Server 2005   |   Visual Basic 2005   |   c# 2005   |   VS 2005   |   Visual Source Safe 2005

MS Dynamics CRM 3.0

SharePoint Portal Server 2003
SharePoint Server 2007
Dynamics NAV
Dynamics CRM
SharePoint Designer 2007
SharePoint Portal Server 2001
Windows SharePoint Services
Windows SharePoint Services 3.0
Project Server 2003
Project Server 2007
Dynamics – Point of Sale
Dynamics AX
Dynamics GP
Dynamics Retail Management System (RMS)
Dynamics SL
SQL Server 2000
Visual Basic .NET 2003
Visual C# .NET 2003
Visual C++ .NET 2003
Visual C++ 2005
Visual SourceSafe 6.0
Windows Server 2003
Windows Server 2003
Outlook 2003
ADO.NET 1.1
ASP.NET 1.0
Visual Studio Team Foundation Server
Visual Studio 2005 Team Edition
Windows Internet Explorer 7
BizTalk Server 2000
BizTalk Server 2002
BizTalk Server 2004
BizTalk Server 2006
Visual Studio 6.0
Access 2000
Access 2002
Access 2003
Access 2007
Access 97
Collaboration Data Objects 2.0
Commerce Server 2002
Content Management Server 2001
Commerce Server 2007
Content Management Server 2002
Data Access Components 2.7
Data Access Components 2.8
DirectX 9.0b
Office Small Business Accounting 2006
Accounting 2007
ActiveSync 4.1
Class Server 2.0
Groove 2007
Windows Vista
Outlook 2007
OneNote 2003
OneNote 2007
Office X for Mac
Zune software
Zune Live
Zoo Tycoon 2
Flight Simulator 2002
Dungeon Siege II

Cervo Technologies
The Right Source to Outsource

Oracle Database FAQS

Sharepoint Portal Server KB

Outlook 2007 Knowledge Base Articles

Visual Studio 6.0 Knowledge Base Articles

This article demonstrates the use of the Web Distributed Authoring and Versioning (WebDAV) MOVE method to move a mail item from one folder to another.


This article demonstrates the use of the Web Distributed Authoring and Versioning (WebDAV) MOVE method to move a mail item from one folder to another.

MORE INFORMATION

The following Visual C++ code sample uses the HTTPRequest object to send a MOVE request to the Exchange server. This sample requires Msxml.dll version 2.0 or later.

To run this sample, follow these steps:
1.Under Public folders, create two new folders and name them "Testfolder1" and "Testfolder2".
2.In Testfolder1, create a mail item with the subject "test".
3.In Visual C++, create a new Win 32 console application and name it "Mysample".
4.Replace the code in the Mysample.cpp file with the following code:
#include<stdio.h>

//TODO: Change the path here if your Msxml.dll file is in a different location.

#import "c:\winnt\system32\msxml.dll"
using namespace MSXML;

//To  use MSXML 4.0 import the dll msxml4.dll instead of msxml.dll as follows 
// #import "c:\winnt\system32\msxml4.dll"
// using namespace MSXML2;

int main(int argc, char* argv[])
{
   CoInitialize(NULL);
   try
   {
   //TODO: Change the line below to reflect your server.
   bstr_t yourServerName = "YourExchangeServername";

   bstr_t sSourceUrl = "http:/" + yourServerName + 
      "/public/TestFolder1/test.eml";
   bstr_t sDestUrl = "http:/" + yourServerName + 
      "/public/TestFolder2/test.eml";
   bstr_t sMethod = "MOVE";
         
   //TODO: Change the 2 lines below to reflect your user name and password.
   _variant_t vUser = L"YourDomain\\Administrator";
   _variant_t vPassword = L"password";
   
   
   // To use MSXML 4.0 use the following declaration and creation of   pXMLHttpReq
   // IXMLHTTPRequestPtr pXMLHttpReq= NULL;
   // HRESULT hr=pXMLHttpReq.CreateInstance("Msxml2.XMLHTTP.4.0");

   MSXML::IXMLHttpRequest* pXMLHttpReq=NULL;     
   HRESULT hr = ::CoCreateInstance(__uuidof(XMLHTTPRequest), 
               NULL, 
               CLSCTX_INPROC_SERVER, 
               __uuidof(IXMLHttpRequest), 
               (LPVOID*)&pXMLHttpReq);
          

   if (S_OK != hr)
   {
      printf("XML Http Request pointer creation failed\n");
      return 0;
   }

   // Call open function.
   _variant_t vAsync = (bool)FALSE;
   pXMLHttpReq->open(sMethod, 
         sSourceUrl, 
         vAsync, 
         vUser, 
         vPassword);

   pXMLHttpReq->setRequestHeader((bstr_t)"Destination", sDestUrl);
 

   // Send the request to set the search criteria.
   pXMLHttpReq->send();


   // OK, get response.   
   long lStatus;
   pXMLHttpReq->get_status(&lStatus);

   printf("\n~~~~~~~~\n%d\n", lStatus);
   BSTR bstrResp;
   pXMLHttpReq->get_statusText(&bstrResp);
   printf("\n~~~~~~~~\n%s\n", (char*)(bstr_t)bstrResp);

   _bstr_t bstrAllHeaders;
   bstrAllHeaders = pXMLHttpReq->getAllResponseHeaders();
   printf("\n~~~~~~~~\n%s\n", (char*)bstrAllHeaders);

   BSTR bstrResponseText;
   pXMLHttpReq->get_responseText(&bstrResponseText);
   printf("\n~~~~~~~~\n%s\n", (char*)(bstr_t)bstrResponseText);      
   }
   catch(_com_error &e)
   {
   printf("Error\a\a\n\tCode = %08lx\n"
      "\tCode meaning = %s\tSource = %s\n\tDescription = %s\n",
      e.Error(), 
      e.ErrorMessage(), 
      (char*)e.Source(), 
      (char*)e.Description() );
   }

   CoUninitialize(); 
   
   return 0;
} 
					
5.Make the changes marked by "TODO:" in the code.
6.Compile and then run the code.

Note that the test.eml mail item is no longer in Testfolder1, but is instead in Testfolder2.


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 Core Services 4.0
Microsoft Visual C++ 6.0 Enterprise Edition
Microsoft Visual C++ 6.0 Professional Edition
Microsoft Visual C++ 6.0 Standard Edition

Keywords: 
kbhowto kbmsg KB290197
Copyright © 2004 - 2007 Gridview.org, Inc. All rights reserved. Powered by Smart Web Content Management System