We exported information from a customer's Address book using outlook. Now he wants that information maintained and updated using Exchange.
We decided to use the Exchange Webservices API for this purpose.
I can retrieve the Contacts, and within those Contacts is the PhysicalAddresses enumeration that contains Work, Home and Other addresses.
Those addresses are instances of the PhysicalAddressEntry class.
This class contains Street address, Postal code, City, State and Region/Country. (See: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.physicaladdressentry_members(v=exchg.80).aspx )
It does not however contain the PostOfficeBox fields which Outlook address items have:
- BusinessAddressPostOfficeBox
- HomeAddressPostOfficeBox
- MailingAddressPostOfficeBox
- OtherAddressPostOfficeBox
(See: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/contactitem-object-outlook )
The Exchange Webservices API does have a PersonaPostalAddress Class which is more detailed than the PhysicalAddressEntry Class ( See: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.personapostaladdress_properties(v=exchg.80).aspx ). That one does have a PostOfficeBox member.
I have not succeeded in obtaining PersonaPostalAddress entries out of my Contacts (See: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.contact_properties(v=exchg.80).aspx )
Is there a way to read and possibly write the PostOfficeBox field that belongs to a certain address ?
There is a 'user defined' property that we are already reading as an extended property, those are in the PublicStrings namespace. (See: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.defaultextendedpropertyset(v=exchg.80).aspx )
I tried creating an extended property called "OtherAddressPostOfficeBox" as PublicStrings, Address and Common, but I haven't succeeded in getting it returned.
Forgive the openedge / progress code but here is what I tried:
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.
We can read the custom Continent/Regio
field this way, but not the PostOfficeBox fields.
I probably need the numeric ID's of these fields to use one of the other constructors of the ExtendedPropertyDefinition class (See: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.extendedpropertydefinition_members(v=exchg.80).aspx ) but I can't seem to find them.
I tried this, after finding that 0x3A64 (14948) might be the ID for OtherAddressPostOfficeBox but that didn't work either.
ASSIGN OtherAddressPostOfficeBox = NEW Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet:Address,14948,Microsoft.Exchange.WebServices.Data.MapiPropertyType:String).
Did I use the correct Property Identifier ? Would it work this way or do I need to do something entirely different ?
Edit: I'm running a brute force attack on these Address fields on an Exchange Contact Item for which I filled in every available field with the name of the field. For most of them Exchange responds with an internal server error, however, from 32768 onwards, the fields start to appear periodically.
I can as of now confirm that ID 0x804A / 32842 corresponds with BusinessAddressPostOfficeBox, so expect an answer to be added shortly once the others have popped up. Do feel free to comment if you happen to know how to pull a PersonaPostalAddress directly from the server.
We have Microsoft Exchange Server 2010 SP3 (14.3.123.4002)