Google Email Labels Fix

This is a fix for Google Contacts where contacts has been created with a custom email label.

Email with custom email labels will not sync to Windows Phone 8.1.

This happen in particular when using GO Contact Sync Mod with Microsoft Outlook.

So when the new contact is created it looks like this:

image

What we need is a label like “Work” or “Home”:

image

I have made a little Goggle apps script to fix this:

function fixcontacts() {
//  var contacts = ContactsApp.getContactGroup(‘My Contacts’).getContacts();  
  var contacts = ContactsApp.getContacts();  
  Logger.log(‘Start…’)
    for (var i in contacts) {
      var addressFields = contacts[i].getAddresses();
//      Logger.log(contacts[i].getFullName());
      var emails = contacts[i].getEmails();
      for (var j in emails) {
        var label=emails[j].getLabel()
//        Logger.log(label);
        switch (label) {
          case ContactsApp.Field.WORK_EMAIL:
//            Logger.log(‘OK’);
            break;
          case ContactsApp.Field.HOME_EMAIL:
//            Logger.log(‘OK’);
            break;
          default:
//            Logger.log(‘FIX’);
            Logger.log(‘Fixing ‘ + contacts[i].getFullName());
            switch (j){
              case ‘0’:
                emails[j].setLabel(ContactsApp.Field.WORK_EMAIL);
                break;
              case ‘1’:
                emails[j].setLabel(ContactsApp.Field.HOME_EMAIL);
                break;
              default:
                emails[j].setLabel(‘Custom’);
                break;
            }
            break;
        }
      }
    }
}

The script will ignore contacts already having the standard labels “Work” and”Home”.

Anything else with get replace with first “Work” and then “Home” for the second label.

Any subsequent labels will not be changed.

If you are not sure how to create and run scripts then read this Google page.

Oh by the way – using this script is on your own responsibility and there is NO support!