在 Exchange Server SOAP 请求中检索扩展的专有业务地址

Retrieve the extended propery Business Addresses in a exchange server soap request

提问人:alaa_sayegh 提问时间:11/16/2023 更新时间:11/18/2023 访问量:46

问:

我在从交换服务器()获取通过请求的BusinessAddressesArray属性(扩展属性)时遇到了一些麻烦。这是请求:version 2016personasoapXML

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <soap:Header>
        <t:RequestServerVersion Version="Exchange2016" />
    </soap:Header>
    <soap:Body>
        <FindPeople xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
         <PersonaShape>
        <t:BaseShape>IdOnly</t:BaseShape>
         <t:AdditionalProperties>
          <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyType="StringArray" />
          <!-- Add other extended properties as needed -->
        </t:AdditionalProperties>
      </PersonaShape>
            <IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="1000" Offset="9000"/>
            <ParentFolderId>
                <t:FolderId Id="MY_FOLDER_ID"/>
            </ParentFolderId>
        </FindPeople>
    </soap:Body>
</soap:Envelope>

这里主要是这部分:

<t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyType="StringArray" />

我无法以 propor 方式构建它以检索角色的业务地址。

C# Outlook Exchange-Server ExchangeWebServices

评论


答:

0赞 alaa_sayegh 11/18/2023 #1

还行。我自己整理了一下。将来谁遇到这个问题,似乎不可能使用端点找出业务地址。经过太多的调查,我找到了通过端点所需的数据,但在另一个属性名称下:这完全误导了我。FindPeopleGetItemPhysicalAddresses

下面是我执行的 XML soap 请求的示例:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <soap:Header>
        <t:RequestServerVersion Version="Exchange2016" />
    </soap:Header>
    <soap:Body>
    <GetItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
      <ItemShape>
        <t:BaseShape>Default</t:BaseShape>
      </ItemShape>
      <ItemIds>
        <t:ItemId Id="YOUR_ITEM-OR-CONTACT_ID" ChangeKey="YOUR_CHANGE_KEY" />
      </ItemIds>
    </GetItem>
  </soap:Body>
</soap:Envelope>

下面是响应示例:

 <t:PhysicalAddresses>
    <t:Entry Key="Business">
       <t:Street>TEST_STREET 22a</t:Street>
       <t:City>TEST_CITY</t:City>
       <t:CountryOrRegion>D</t:CountryOrRegion>
       <t:PostalCode>123456</t:PostalCode>
    </t:Entry>
 </t:PhysicalAddresses>

此外,通过该服务,可以像这样检索它:EWS

var globalFolder = new FolderId(WellKnownFolderName.MyContacts);
var view = new ItemView(50, 0);
var items = await exchangeService.FindItems(globalFolder, view);

foreach (var item in items)
{
    if (item is Contact contact)
    {
        contact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Business, out var address);
        Console.WriteLine(address.City);

        Console.WriteLine($"Display Name: {contact.DisplayName}");
        Console.WriteLine($"First Name: {contact.GivenName}");
        Console.WriteLine($"Last Name: {contact.Surname}");
        Console.WriteLine($"Company name: {contact.CompanyName}");
        Console.WriteLine($"Company website: {contact.BusinessHomePage}");

        contact.EmailAddresses.TryGetValue(EmailAddressKey.EmailAddress1, out var emailAddress1);
        Console.WriteLine($"Email 1: {emailAddress1.Address}");
    }
}