CreateFolder 操作CreateFolder operation

CreateFolder 操作将创建文件夹、日历文件夹、联系人文件夹、任务文件夹和搜索文件夹。The CreateFolder operation creates folders, calendar folders, contacts folders, tasks folders, and search folders.

CreateFolder 请求示例CreateFolder request example

DescriptionDescription

以下示例的 CreateFolder 请求显示如何在邮箱根目录中形成创建两个新文件夹的请求。The following example of a CreateFolder request shows how to form a request to create two new folders in the mailbox root.

代码Code

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <CreateFolder xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <ParentFolderId>
        <t:DistinguishedFolderId Id="msgfolderroot"/>
      </ParentFolderId>
      <Folders>
        <t:Folder>
          <t:DisplayName>Folder1</t:DisplayName>
        </t:Folder>
        <t:Folder>
          <t:DisplayName>Folder2</t:DisplayName>
        </t:Folder>
      </Folders>
    </CreateFolder>
  </soap:Body>
</soap:Envelope>

Request 元素Request elements

请求中使用以下元素:The following elements are used in the request:

备注

描述这些元素的架构位于运行 MicrosoftExchange Server 2007 且安装了客户端访问服务器角色的计算机的 EWS 虚拟目录中。The schema that describes these elements is located in the EWS virtual directory of the computer that is running MicrosoftExchange Server 2007 that has the Client Access server role installed.

若要查找 CreateFolder 操作的请求消息的其他选项,请浏览架构层次结构。To find other options for the request message of the CreateFolder operation, explore the schema hierarchy. CreateFolder元素开始。Start at the CreateFolder element.

备注

如果使用calendar:管理器属性创建具有限制的搜索文件夹,后续的 get 文件夹调用将返回限制,并显示邮件的位置 : from属性。If you create a search folder with a restriction by using the calendar:Organizer property, a subsequent get folder call will return the restriction with the message:from property in its place. 这两个属性映射到相同的基础 MAPI 属性。These two properties map to the same underlying MAPI property.

仅当使用通用文件夹 type 元素创建文件夹并设置FolderClass元素时,CreateFolder 操作才支持创建自定义文件夹类。The CreateFolder operation supports the creation of a custom folder class only when you create the folder by using a generic folder type element and set the FolderClass element.

成功的 CreateFolder 响应示例Successful CreateFolder response example

DescriptionDescription

下面的示例演示对 CreateFolder 请求的成功响应。The following example shows a successful response to the CreateFolder request. 在此示例中,响应返回新文件夹的标识符。In this example, the response returns the identifiers of the new folders.

备注

文件夹 ID 和更改密钥已缩短,以保持可读性。The folder ID and the change key have been shortened to preserve readability.

代码Code

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="595" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <CreateFolderResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                          xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                          xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:CreateFolderResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Folders>
            <t:Folder>
              <t:FolderId Id="AS4AUn==" />
            </t:Folder>
          </m:Folders>
        </m:CreateFolderResponseMessage>
        <m:CreateFolderResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Folders>
            <t:Folder>
              <t:FolderId Id="AS4AUn==" />
            </t:Folder>
          </m:Folders>
        </m:CreateFolderResponseMessage>
      </m:ResponseMessages>
    </CreateFolderResponse>
  </soap:Body>
</soap:Envelope>

成功的响应元素Successful response elements

响应中使用以下元素:The following elements are used in the response:

若要查找 CreateFolder 操作的响应邮件的其他选项,请浏览架构层次结构。To find other options for the response message of the CreateFolder operation, explore the schema hierarchy. CreateFolderResponse元素开始。Start at the CreateFolderResponse element.

CreateFolder 错误响应CreateFolder error response

DescriptionDescription

下面的示例演示对 CreateFolder 请求的错误响应。The following example shows an error response to a CreateFolder request.

代码Code

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="595" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <CreateFolderResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                          xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                          xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:CreateFolderResponseMessage ResponseClass="Error">
          <m:MessageText>A folder with the specified name already exists.</m:MessageText>
          <m:ResponseCode>ErrorFolderExists</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
          <m:Folders />
        </m:CreateFolderResponseMessage>
      </m:ResponseMessages>
    </CreateFolderResponse>
  </soap:Body>
</soap:Envelope>

错误响应元素Error response elements

错误响应中使用以下元素:The following elements are used in the error response:

若要查找 CreateFolder 操作的错误响应消息的其他选项,请浏览架构层次结构。To find other options for the error response message of the CreateFolder operation, explore the schema hierarchy. CreateFolderResponse元素开始。Start at the CreateFolderResponse element.

另请参阅See also

FindItem 操作FindItem operation

FindFolder 操作FindFolder operation

CreateFolderTypeCreateFolderType

Creating Folders (Exchange Web Services)Creating Folders (Exchange Web Services)