次の方法で共有


Converting EWS Identifiers in Exchange 2010

Last modified: October 14, 2009

Applies to: Exchange Server 2007 | Exchange Server 2010

You can use Exchange Web Services to convert identifiers to other identifier formats that are exposed by Microsoft Exchange Server 2010. This is important because the Exchange Web Services identifier format changed between the initial release version of Exchange Server 2007 and Exchange Server 2007 Service Pack 1 (SP1) (Exchange 2010 uses the same identifier format as Exchange 2007 SP1.) You can use the ConvertId Operation to convert between the following identifier formats:

  1. The initial release version of Exchange 2007 Exchange Web Services identifier format. This is represented by the EwsLegacyId enumeration value in IdFormatType.

  2. The Exchange 2007 SP1 or Exchange 2010 Exchange Web Services identifier. This is represented by the EwsId enumeration value in IdFormatType.

  3. The MAPI identifier, as in the PR_ENTRYID property. This is represented by the EntryId enumeration value in IdFormatType.

  4. The availability calendar event identifier. This is a hexadecimal-encoded representation of the PR_ENTRYID property. This is represented by the HexEntryId enumeration value in IdFormatType.

  5. The Exchange store identifier. This is represented by the StoreId enumeration value in IdFormatType.

  6. The Outlook Web Access identifier. This is represented by the OwaId enumeration value in IdFormatType. Passing URLs that are created from this identifier to Outlook Web Access is not supported.

Important

Make sure that the RequestServerVersion SOAP header is set for all Exchange 2010 requests.

Note

The ConvertId Operation validates that a given SMTP address has a valid format. The ConvertId operation does not check to determine whether an SMTP address represents a valid mailbox.

Example

The following code example shows how to convert from an Outlook Web App identifier to a PR_ENTRYID identifier. For information about how to set the RequestServerVersion SOAP header on the ExchangeServiceBinding object, see Versioning EWS Requests in Exchange 2010.

static void ConvertId(ExchangeServiceBinding esb)
{
    // Create a request to convert identifiers.
    ConvertIdType request = new ConvertIdType();
    request.SourceIds = new AlternateIdType[1];
    request.SourceIds[0] = new AlternateIdType();

    // Convert from the Outlook Web Access identifier format to an PR_ENTRYID identifier.
    request.SourceIds[0].Format = IdFormatType.OwaId;
    (request.SourceIds[0] as AlternateIdType).Id = "RgAAAAAS2%";
    (request.SourceIds[0] as AlternateIdType).Mailbox = "User1@example.com";
    request.DestinationFormat = IdFormatType.EntryId;

    try
    {
        // Send the request and get the response.
        ConvertIdResponseType response = esb.ConvertId(request);

        ResponseMessageType[] rmta = response.ResponseMessages.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            ConvertIdResponseMessageType cirmt = (rmt 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);
            Console.ReadLine();
        }
    }

    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}