Compartir a través de


CopyFolderType Class

The CopyFolderType class represents an operation to copy folders in an Exchange database.

Namespace: ExchangeWebServices
Assembly: EWS (in ews.dll)

Syntax

'Declaration
<SerializableAttribute> _
<DesignerCategoryAttribute("code")> _
<XmlTypeAttribute(Namespace:="https://schemas.microsoft.com/exchange/services/2006/messages")> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<DebuggerStepThroughAttribute> _
Public Class CopyFolderType
    Inherits BaseMoveCopyFolderType
[SerializableAttribute] 
[DesignerCategoryAttribute("code")] 
[XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages")] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[DebuggerStepThroughAttribute] 
public class CopyFolderType : BaseMoveCopyFolderType
[SerializableAttribute] 
[DesignerCategoryAttribute(L"code")] 
[XmlTypeAttribute(Namespace=L"https://schemas.microsoft.com/exchange/services/2006/messages")] 
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")] 
[DebuggerStepThroughAttribute] 
public ref class CopyFolderType : public BaseMoveCopyFolderType
/** @attribute SerializableAttribute() */ 
/** @attribute DesignerCategoryAttribute("code") */ 
/** @attribute XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DebuggerStepThroughAttribute() */ 
public class CopyFolderType extends BaseMoveCopyFolderType
SerializableAttribute 
DesignerCategoryAttribute("code") 
XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
DebuggerStepThroughAttribute 
public class CopyFolderType extends BaseMoveCopyFolderType

Remarks

The CopyFolder operation copies folders and all their contents while the content is maintained in the same structure. The copied folders will have new folder identifiers and change keys.

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
     ExchangeWebServices.BaseMoveCopyFolderType
      ExchangeWebServices.CopyFolderType

Example

The following code example shows you how to copy two folders to a destination folder and then get the new folder identifiers.

static void CopyFolder(ExchangeServiceBinding esb)
{
    // Identify the folders to copy.
    FolderIdType folder1 = new FolderIdType();
    FolderIdType folder2 = new FolderIdType();
    folder1.Id = "AQAlAE1BQG1haW5";
    folder2.Id = "AQAlAE1BQG1haW4";
    FolderIdType[] folders = new FolderIdType[2] { folder1, folder2 };

    // Identify the destination folder.
    FolderIdType destFolder = new FolderIdType();
    destFolder.Id = "AQAlAE1BQG1haW1";

    // Form the copy folder request.
    CopyFolderType request = new CopyFolderType();
    request.FolderIds = folders;
    request.ToFolderId = new TargetFolderIdType();
    request.ToFolderId.Item = destFolder;

    try
    {
        // Send the request and get the response.
        CopyFolderResponseType response = esb.CopyFolder(request);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Success)
            { 
                foreach (BaseFolderType folder in (rmt as FolderInfoResponseMessageType).Folders)
                {
                    // Get the new folder ID and change key.
                    FolderIdType identifier = folder.FolderId;
                }
            }
            else
            {
                throw new Exception("Folder copy failed.");
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)