views:

198

answers:

1

I'm trying to clean up my outlook 2003 contacts, which has become a rather ugly mess of various formatting, etc.

Basically, I have a bunch of contacts, in the form of either:

0xxxxxxxxx [ten digits, starting with 0] 0xxxxxxxx [nine digits, starting with 0] 0xxxxxxxx (xxxxx) [the same nine digits above with the last five repeated in parentheses] +xxxxxxx [some random "complete" number with an international dialing code, etc]

I want all of the numbers to match the last format. The algorithm is simple enough: for the first two types, drop the 0 and add +YYY where YYY is my country code. Ditto for the third, but drop everything in parentheses.

My problem is that I don't know how to go about doing this. I've written a million scripts in my life in Perl, but I'd rather not export everything to text, process it, and re-import; I'd like to have a one-click solution that can easily be re-run (such as when I import a new contact from my companies' directory which comes in one of the forms above). I suspect that VBScript is the way to go; I've seen a few references online to accessing contacts as objects, but I'm not really sure what the best way to get started is.

Any recommended resources?

This is a duplicate of http://superuser.com/questions/15913/script-to-modify-outlook-2003-contacts ; I'm not sure which site is a better location

+1  A: 

I would say VBA, rather than VBScript.

Sub GetContactsTel()

    Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    ' Loop through all of the items in the folder.
    For i = 1 To oFolder.Items.Count
       Debug.Print oFolder.Items(i).BusinessTelephoneNumber
    Next

End Sub
Remou