grahamr975 / EWS-Office365-Contact-Sync

Uses Exchange Web Services to synchronize a Global Address List in Office 365 to a user's mailbox
MIT License
96 stars 21 forks source link

Exclude Country Code or Area Code in Phone number #48

Closed nldenic closed 2 years ago

nldenic commented 2 years ago

Hi @grahamr975,

Is there an option to exclude an prefix in the phone number ?

Now its adding our Area code in the contacts. Its not an big issue but android does not get it correctly

So it adds the users number as : +31(0)61234567

I want to be able to add the number as : +3161234567

So exclude (0). Do you think this is possible to write this in the Set-exccontact.ps1 or other ps1 ?

Thank you for your time.

nldenic commented 2 years ago

Hi @grahamr975

Do you have an simple sollution for this ?

My users are now not able to call the phone numbers because its calling +31061234567

The area code is an big issue for iphone.

grahamr975 commented 2 years ago

@nldenic

Can you please format your GAL/contact numbers per the format below and let me know if this helps? In our iPhone environment, we have no issues with area code.

+X XXX XXX XXXX

nldenic commented 2 years ago

@grahamr975

At the moment the Telephone number field is : +31 (0)20 xxx xx xx

This is because the teams is also gettings thie field as number and also the signature tool foor outlook.

But now the script is gettings this number and adding to the contacts list with +31 (0)20 xxx xx xx so its not working when you want to dial with the iphone.

When the person change this to +31 20 xxx xx xx it works for them. So (0) is not recognisable by iphone als now android :D

grahamr975 commented 2 years ago

@nldenic I don't see myself adding a feature for handling "(0)" in the official script since I don't recommend that practice. As a workaround, you could modify the Get-Contacts.ps1 function to clean all instances of "(0)" from the Phone and MobilePhone fields using the Replace() string method. See below for an example.

Foreach ($Contact in $ContactList) {
  $Contact.Phone = $Contact.Phone.Replace("(0)","")
  $Contact.MobilePhone = $Contact.MobilePhone.Replace("(0)","")
  }
return $ContactList | Where-Object {$null -ne $_.WindowsEmailAddress -and "" -ne $_.WindowsEmailAddress}

Regards, Ryan