Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Script to change contacts phone numbers

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
thirtysomething
Asked:
thirtysomething
  • 3
  • 2
1 Solution
 
Patrick MatthewsCommented:
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
 
thirtysomethingAuthor Commented:
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
 
Patrick MatthewsCommented:
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
 
thirtysomethingAuthor Commented:
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
 
Patrick MatthewsCommented:
Glad to help :)
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now