* Program....: PARSEADDRESS.PRG * Version....: 1.0 * Author.....: Andrew Coates * Date.......: April 15, 2001 * Notice.....: Copyright © 2001 Civil Solutions, All Rights Reserved. * Compiler...: Visual FoxPro 06.00.8961.00 for Windows * Abstract...: Parses an address using the outlook address parser. * Simply displays components using a message box, but you could populate an object * with the info if you wanted to - wait, you already have an object populated with the info * the contact object. * Usage......: ? ParseAddress("Level 2" + chr(13) + "549-553 Pacific Highway" + chr(13) + "CROWS NEST, NSW 2062") * Changes....: lParameters tcAddress local lcAddress * simply for testing lcAddress = iif(vartype(tcAddress) = "C", tcAddress, "PO Box 1510" + chr(13) + "MAROUBRA NSW 2035" + chr(13) + "AUSTRALIA") #DEFINE olContactItem 2 local oApp, oContact * create a new contact oApp = createobject("outlook.application") oContact = oApp.CreateItem(olContactItem) * put the address in as a long string oContact.BusinessAddress = lcAddress * don't need to call it anything - just use it and discard it! * oContact.FileAs = "Temp Contact" * don't even need to save the contact * oContact.Save * read the components MessageBox(oContact.BusinessAddressStreet, 0, "Street") MessageBox(oContact.BusinessAddressPostOfficeBox, 0, "PO Box") MessageBox(oContact.BusinessAddressCity, 0, "Suburb") MessageBox(oContact.BusinessAddressState, 0, "State") MessageBox(oContact.BusinessAddressPostalCode, 0, "Post Code") MessageBox(oContact.BusinessAddressCountry, 0, "Country") * not required because we didn't save * oContact.DeleteLooks pretty good on the limited testing data I used - I have a feeling that it uses the computer's current country to work out what country to assign if there's not a country in the address.