我们使用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)