다음을 통해 공유


GetItemType Class

The GetItemType class represents a request to get items from a mailbox in the Exchange database.

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

Syntax

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

Remarks

The GetItem and FindItem operations provide a similar set of information. The GetItem operation is used to get items after they have been found by using FindItem, GetEvents, or SyncFolderItems operations.

GetItem returns additional properties that are not returned by FindItem. The following table shows properties not returned by FindItem but are returned by GetItem.

Properties returned only by GetItem

Attachments

Categories

ReplyTo

Body

CcRecipients

ResponseObjects

BccRecipients

InternetMessageHeaders

ToRecipients

Starting with Exchange Server 2007 Service Pack 1 (SP1) with Update Rollup 4 (RU4) applied, Exchange Web Services (EWS) uses CPU-limited throttling in the GetItem operation to ensure that other processes on the Client Access server are not affected by an application that makes a high volume of GetItem requests in a short period of time. When the EWS process exceeds 50% CPU utilization, all requests will be forced to yield a small amount of time to limit EWS CPU utilization to 50%. (This value is configurable in web.config.) The delay is evenly distributed among all incoming requests.

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.GetItemType

Example

The following example shows how to get two items from the Exchange database. The request uses the default response shape with the Sensitivity property returned as an additional property. The response is checked for e-mail messages and calendar items. Be aware that if the only properties that are accessed are contained in the base ItemType class, casting to the appropriate type may not be necessary.

static void GetItem(ExchangeServiceBinding esb)
{ 
    // Create the request.
    GetItemType request = new GetItemType();

    // Create the response shape.
    ItemResponseShapeType responseShape = new ItemResponseShapeType();
    responseShape.BodyType = BodyTypeResponseType.Text;
    responseShape.BodyTypeSpecified = true;
    responseShape.BaseShape = DefaultShapeNamesType.Default;
    // Add more properties to the request.
    PathToUnindexedFieldType[] sensitivity = new PathToUnindexedFieldType[1];
    sensitivity[0] = new PathToUnindexedFieldType();
    sensitivity[0].FieldURI = UnindexedFieldURIType.itemSensitivity;
    responseShape.AdditionalProperties = sensitivity;
    // Add the response shape to the request.
    request.ItemShape = responseShape;

    // Identify the items to get.
    ItemIdType[] items = new ItemIdType[2];
    items[0] = new ItemIdType();
    items[0].Id = "AAAlAE1BQG1";
    items[0].ChangeKey = "DwAAABYAAAA";
    items[1] = new ItemIdType();
    items[1].Id = "AAAlAE1BQG1";
    items[1].ChangeKey = "DwAAABYAAAA";

    // Add items to the request.
    request.ItemIds = items;

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

        foreach (ResponseMessageType rmt in rmta)
        {
            ItemInfoResponseMessageType iirmt = (rmt as ItemInfoResponseMessageType);
            ArrayOfRealItemsType aorit = iirmt.Items;
            ItemType[] myItems = aorit.Items;
            
            // Determine the type for each item and cast to the approriate type.
            foreach (ItemType it in myItems)
            {
                // Determine whether it is an e-mail.
                if (it is MessageType)
                {
                    MessageType message = (it as MessageType);
                }
                // Determine whether it is a calendar item.
                else if (it is CalendarItemType)
                {
                    CalendarItemType calendar = (it as CalendarItemType);
                }
                else 
                {
                    // Check for other item types.
                }
            }
        }
    }
    catch (Exception e)
    {
        throw new Exception("GetItem failed");
    }
}

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)