Solved

Script to change contacts phone numbers

Posted on 2006-11-22
5
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

617 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