Solved

Script to change contacts phone numbers

Posted on 2006-11-22
5
298 Views
Last Modified: 2010-04-08
Hi,

Just changed my phone & my new phone wont show the callers name as the phone numbers are in a different format, ie there is no international dialing code.  I syncronise with my outlook contacts (no prises for guessing what kinda phone!)

So  I am looking for a script (preferabally a cscript as we will be rolling these phones out to a number of other people shortly) that I can run that will update the phone numbers in my outlook contacts, and prefix them with the international dialing code.

If I have the code that would open, alter & save the update, I could customise to suit.  Eg some numbers will have area codes, some will be local only etc so it will take a bit of tuning to get right.

regards

J
0
Comment
Question by:thirtysomething
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17998151
Hi J,

> Eg some numbers will have area codes, some will be local only etc so it will take
> a bit of tuning to get right.

Please detail all the rules you want applied to the phone numbers.

Also, be advised that running this kind of script may very well trigger an Outlook security warning, so make sure
the other people running this script will know how to respond.

Regards,

Patrick
0
 

Author Comment

by:thirtysomething
ID: 18000276
Patrick,

Thanks for the feedback.

The rules will have to develop.  I have enough programming ability (just about) to do the detailed numbers changing if I had a base script to work off.  Looking at my own 900ish contacts they are in a mess so it will take a few goes.

For the other users, we will be working with them on a one to one basis running contact duplicate removers, moving contacts from SIMs etc so will be running it with them.  To have to go through phone numbers individually would do everybodys nut in.  We would probabally run it on behalf of the users

A sample would be if phone number starts with 087 change it to +353 (87)....

J

Cá bhuil tú i do chónaí?
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 499 total points
ID: 18000443
J,

You could start with this VBScript:




Sub ModifyPhone()

    Dim olApp, olNS, olMF, olContact

    Set olApp = CreateObject("Outlook.Application")
    Set olNS = olApp.GetNameSpace("MAPI")
    Set olMF = olNS.GetDefaultFolder(10) 'Contacts

    For Each olContact In olMF.Items
        If olContact.Class = 40 Then
            'put in your code here for phone number stuff
            'many properties available
            'AssistantTelephoneNumber
            'BusinessTelephoneNumber
            'Business2TelephoneNumber
            'CallbackTelephoneNumber
            'CarTelephoneNumber
            'CompanyMainTelephoneNumber
            'HomeTelephoneNumber
            'MobileTelephoneNumber
            'OtherTelephoneNumber
            'PrimaryTelephoneNumber
            'RadioTelephoneNumber
            'TTYTDDTelephoneNumber
        End If
    Next

    Set olContact = Nothing
    Set olMF = Nothing
    Set olNS = Nothing
    Set olApp = Nothing

End Sub

Regards,

Patrick
0
 

Author Comment

by:thirtysomething
ID: 18002425
Patrick,

Perfect!!!!

I wrote a subroutine called fixnumber to do the tidying for a given number & added the following to your code.  These are the main fields of interest to me, the only ones I had to add were the fax numbers

        olContact.HomeTelephoneNumber  = fixnumber(olContact.HomeTelephoneNumber )
        olContact.AssistantTelephoneNumber  = fixnumber(olContact.AssistantTelephoneNumber )
        olContact.BusinessTelephoneNumber  = fixnumber(olContact.BusinessTelephoneNumber )
        olContact.Business2TelephoneNumber  = fixnumber(olContact.Business2TelephoneNumber )
        olContact.BusinessFaxNumber  = fixnumber(olContact.BusinessFaxNumber )
        olContact.CompanyMainTelephoneNumber  = fixnumber(olContact.CompanyMainTelephoneNumber )
        olContact.HomeTelephoneNumber  = fixnumber(olContact.HomeTelephoneNumber )
        olContact.HomeFaxNumber  = fixnumber(olContact.HomeFaxNumber )
        olContact.MobileTelephoneNumber  = fixnumber(olContact.MobileTelephoneNumber )
        olContact.OtherTelephoneNumber  = fixnumber(olContact.OtherTelephoneNumber )
        olContact.PrimaryTelephoneNumber  = fixnumber(olContact.PrimaryTelephoneNumber )
' save the changes to Outlook
        olContact.save


Full marks for response time & working code sample
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 18003299
Glad to help :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now