Edit

Share via


ConvertIdType Class

Definition

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

public ref class ConvertIdType : ExchangeWebServices::BaseRequestType
public class ConvertIdType : ExchangeWebServices.BaseRequestType
Public Class ConvertIdType
Inherits BaseRequestType
Inheritance
ConvertIdType

Examples

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();
    }
}

Constructors

ConvertIdType()

The ConvertIdType constructor initializes a new instance of the ConvertIdType class.

Properties

DestinationFormat

The DestinationFormat property gets or sets the identifier format that will be returned for all the converted identifiers.

SourceIds

The SourceIds property gets or sets an AlternativeIdBaseType array that contains the source identifiers to convert.

Applies to