2017-08-04 94 views
0

我们使用Outlook从客户的地址簿导出信息。 现在他希望使用Exchange维护和更新信息。如何使用Exchange Web服务(EWS)访问联系人的PostOfficeBox?

我们决定为此使用Exchange Webservices API。

我可以检索联系人,并且在这些联系人中包含PhysicalAddresses枚举,其中包含工作,家庭和其他地址。

这些地址是PhysicalAddressEntry类的实例。

此课程包含街道地址,邮政编码,城市,州和地区/国家。 (参见:https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.physicaladdressentry_members(v=exchg.80).aspx

但是,它没有包含的Outlook地址项具有PostOfficeBox领域:

  • BusinessAddressPostOfficeBox
  • HomeAddressPostOfficeBox
  • MailingAddressPostOfficeBox
  • OtherAddressPostOfficeBox

(见:https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/contactitem-object-outlook

Exchange Webservices API确实具有比PhysicalAddressEntry类更详细的PersonaPostalAddress类(请参阅:https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.personapostaladdress_properties(v=exchg.80).aspx)。那个确实有一个PostOfficeBox成员。

我还没有成功地获得了我的联系方式的PersonaPostalAddress项(见:https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.contact_properties(v=exchg.80).aspx

有没有一种方法来读取和写入可能属于某个地址的PostOfficeBox场?

有一个'用户定义'属性,我们已经将它作为扩展属性读取,属于PublicStrings命名空间。 (请参阅:https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.defaultextendedpropertyset(v=exchg.80).aspx

我试图创建一个名为“OtherAddressPostOfficeBox”扩展属性作为PublicStrings,Address和Common,但我没有成功地得到它返回。

原谅openedge /进度代码,但这里是我的尝试:

DEFINE VARIABLE continent-regio   AS CLASS Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition NO-UNDO. 
DEFINE VARIABLE OtherAddressPostOfficeBox AS CLASS Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition NO-UNDO. 
DEFINE VARIABLE properties    AS CLASS "Microsoft.Exchange.WebServices.Data.PropertyDefinitionBase[]" NO-UNDO. 
ASSIGN continent-regio = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet:PublicStrings,"Continent/Regio",Microsoft.Exchange.WebServices.Data.MapiPropertyType:String). 
ASSIGN OtherAddressPostOfficeBox = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet:Common,"OtherAddressPostOfficeBox",Microsoft.Exchange.WebServices.Data.MapiPropertyType:String). 

ASSIGN properties = NEW "Microsoft.Exchange.WebServices.Data.PropertyDefinitionBase[]"(3). 
properties:SetValue(continent-regio,0). 
properties:SetValue(Microsoft.Exchange.WebServices.Data.ContactSchema:PostalAddressIndex,1). 
properties:SetValue(OtherAddressPostOfficeBox,2). 

contactlijst:PropertySet = NEW Microsoft.Exchange.WebServices.Data.PropertySet(
    Microsoft.Exchange.WebServices.Data.BasePropertySet:FirstClassProperties, 
    properties). 

DELETE OBJECT properties. 

ASSIGN contacten = service:FindItems(Microsoft.Exchange.WebServices.Data.WellKnownFolderName:Contacts, contactlijst). 

DO iX = 0 TO contacten:Items:COUNT - 1: 
    IF STRING(contacten:Items:Item[iX]:GetType()) EQ "Microsoft.Exchange.WebServices.Data.Contact" THEN DO: /* Mailinglijsten overslaan */ 
     ASSIGN contactpersoon = CAST(contacten:Items:Item[iX], Microsoft.Exchange.WebServices.Data.Contact). 

     DO iY = 0 TO contactpersoon:ExtendedProperties:COUNT - 1: 
      CASE contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:NAME: 
       WHEN continent-regio:NAME THEN ASSIGN tt-cp.continent-regio = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
       WHEN OtherAddressPostOfficeBox:NAME THEN MESSAGE contactpersoon:ExtendedProperties:ITEM[iY]:VALUE 
        VIEW-AS ALERT-BOX INFO BUTTONS OK. 
      END CASE. 
     END. 

     DELETE OBJECT contactpersoon. 
    END. 
END. 

我们可以读取自定义Continent/Regio场这种方式,但不是PostOfficeBox领域。

我可能需要这些字段的数字ID来使用ExtendedPropertyDefinition类的其他构造函数之一(请参阅:https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.extendedpropertydefinition_members(v=exchg.80).aspx),但我似乎无法找到它们。

我试过这个,发现0x3A64(14948)可能是OtherAddressPostOfficeBox的ID,但那也不管用。

ASSIGN OtherAddressPostOfficeBox = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet:Address,14948,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String). 

我使用了正确的属性标识符吗?它会以这种方式工作,还是我需要做一些完全不同的事情?

编辑:我对Exchange联系人项目上的这些地址字段运行强力攻击,为此我填充了字段名称的每个可用字段。对于其中的大部分Exchange而言,内部服务器错误会作出响应,但是,从32768开始,这些字段会开始周期性显示。

我现在可以确认ID 0x804A/32842对应于BusinessAddressPostOfficeBox,所以希望一旦其他人弹出后,很快就会添加一个答案。如果您碰巧知道如何直接从服务器上取得PersonaPostalAddress,请随时发表评论。

我们的Microsoft Exchange Server 2010 SP3(14.3.123.4002)

回答

0

这不是那么简单,因为我以为,因为只有BusinessAddressPostOfficeBox是可以检索出地址DefaultExtendedPropertySet的领域。

然而,有这一个领域我设法找到解释如何让他人在互联网上的以下列表:http://j-integra.intrinsyc.com/support/kb/article.aspx?id=53135

最终我们的代码现在看起来是这样的:

ASSIGN BusinessAddressPostOfficeBox = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet:Address,32842,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     HomeAddressPostOfficeBox  = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14942,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     MailingAddressCity   = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14887,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     MailingAddressCountry  = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14886,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     MailingAddressPostalCode  = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14890,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     MailingAddressPostOfficeBox = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14891,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     MailingAddressState   = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14888,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     MailingAddressStreet   = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14889,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 
     OtherAddressPostOfficeBox = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14948,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String) 

ASSIGN properties = NEW "Microsoft.Exchange.WebServices.Data.PropertyDefinitionBase[]"(10). 
properties:SetValue(continent-regio,0). 
properties:SetValue(BusinessAddressPostOfficeBox,1). 
properties:SetValue(HomeAddressPostOfficeBox,2). 
properties:SetValue(MailingAddressCity,3). 
properties:SetValue(MailingAddressCountry,4). 
properties:SetValue(MailingAddressPostalCode,5). 
properties:SetValue(MailingAddressPostOfficeBox,6). 
properties:SetValue(MailingAddressState,7). 
properties:SetValue(MailingAddressStreet,8). 
properties:SetValue(OtherAddressPostOfficeBox,9). 

contactlijst:PropertySet = NEW Microsoft.Exchange.WebServices.Data.PropertySet(
    Microsoft.Exchange.WebServices.Data.BasePropertySet:FirstClassProperties, 
    properties). 

ASSIGN contacten = service:FindItems(Microsoft.Exchange.WebServices.Data.WellKnownFolderName:Contacts, contactlijst). 

DO iX = 0 TO contacten:Items:COUNT - 1: 
    IF STRING(contacten:Items:Item[iX]:GetType()) EQ "Microsoft.Exchange.WebServices.Data.Contact" THEN DO: /* Mailinglijsten overslaan */ 
     ASSIGN contactpersoon = CAST(contacten:Items:Item[iX], Microsoft.Exchange.WebServices.Data.Contact). 

     CREATE tt-cp. 
     ASSIGN tt-cp.naam    = contactpersoon:CompleteName:FullName 
       tt-cp.firma    = contactpersoon:CompanyName 
       tt-cp.initialen   = contactpersoon:Initials 
       tt-cp.functie   = contactpersoon:JobTitle 
       tt-cp.afdeling   = contactpersoon:Department 
/* ... */ 
     DO iY = 0 TO contactpersoon:ExtendedProperties:COUNT - 1: 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(continent-regio) THEN 
       ASSIGN tt-cp.continent-regio = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(BusinessAddressPostOfficeBox) THEN 
       ASSIGN tt-cp.werkadres-postbus = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(HomeAddressPostOfficeBox) THEN 
       ASSIGN tt-cp.thuisadres-postbus = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(MailingAddressCity) THEN 
       ASSIGN tt-cp.postadres-stad = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(MailingAddressCountry) THEN 
       ASSIGN tt-cp.postadres-land = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(MailingAddressPostalCode) THEN 
       ASSIGN tt-cp.postadres-postcode = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(MailingAddressPostOfficeBox) THEN 
       ASSIGN tt-cp.postadres-postbus = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(MailingAddressState) THEN 
       ASSIGN tt-cp.postadres-staat = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(MailingAddressStreet) THEN 
       ASSIGN tt-cp.postadres-straat = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(OtherAddressPostOfficeBox) THEN 
       ASSIGN tt-cp.anderadres-postbus = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
      IF contactpersoon:ExtendedProperties:ITEM[iY]:PropertyDefinition:Equals(Webpage) THEN 
       ASSIGN tt-cp.webstek = contactpersoon:ExtendedProperties:ITEM[iY]:VALUE. 
     END. 

所以基本上你只要查找标记ID是为你正在寻找的领域,并创建一个扩展属性,然后它将被返回。

当回顾返回的结果集时,可以使用Equals测试propertydefinition以查看返回的是哪一个。

相关问题