Solved

Script to change contacts phone numbers

Posted on 2006-11-22
5
310 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Mailbox Overload?
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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