Sdílet prostřednictvím


ConvertIdType Class

The ConvertIdType class represents a request to convert item and folder identifiers between supported Exchange formats.

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

Syntax

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

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.ConvertIdType

Example

The following example performs an identifier conversion between the Exchange Web Services identifier format and the Outlook Web Access identifier format.

static void ConvertId()
{
    // Set the version, credentials, and the Client Access server on ExchangeServiceBinding.
    ExchangeServiceBinding esb = new ExchangeServiceBinding();
    esb.RequestServerVersionValue = new RequestServerVersion();
    esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
    esb.Credentials = new NetworkCredential("username", "password", "domain");
    esb.Url = "https://FQDN/ews/exchange.asmx";

    // Create the request.
    ConvertIdType request = new ConvertIdType();
    request.SourceIds = new AlternateIdType[1];
    request.SourceIds[0] = new AlternateIdType();

    // Convert from the Exchange Web Services identifier to an Outlook Web Access identifier.
    request.SourceIds[0].Format = IdFormatType.EwsId;
    (request.SourceIds[0] as AlternateIdType).Id = "AAMkADk";
    (request.SourceIds[0] as AlternateIdType).Mailbox = "user@example.com";
    request.DestinationFormat = IdFormatType.OwaId;

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

        // Check each response message.
        foreach (ConvertIdResponseMessageType resp in rmta)
        {
            if (resp.ResponseClass == ResponseClassType.Success)
            {
                ConvertIdResponseMessageType cirmt = (resp as ConvertIdResponseMessageType);
                AlternateIdType myId = (cirmt.AlternateId as AlternateIdType);

                string format = myId.Format.ToString();
                string identifier = myId.Id;
                string mailbox = myId.Mailbox;

                Console.WriteLine("Converted to format: {0}\r\nIdentifier: {1}\r\nMailbox: {2}", format, identifier, mailbox);
            }
            else if (resp.ResponseClass == ResponseClassType.Error)
            {
                Console.WriteLine("Error: " + resp.MessageText);
            }
            else
                Console.WriteLine("Warning: " + resp.MessageText);
        }
        Console.ReadLine();
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

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)