Categories
Facebook Google+ Productivity Technology Twitter

Review a random Google Contact every day

I have all of my contacts loaded into Google Contacts but the problem is, I’m never convinced that they are up to date or even sure if I should still have the person’s contact details listed.

To address this I created the following script which will send me an email every day with a randomly selected contact.

I can then review the contact’s details, compare it with LinkedIn, Facebook and Twitter and then either update their contact details or send them an e-mail to catch up with them.

function reviewContacts() {
  var contacts=ContactsApp.getContacts()
  var contactCount=contacts.length
  var randID=Math.ceil(Math.random()*contactCount)
  var aContact=contacts[randID]
  var contactArray = aContact.getId().split('/')
  var contactID = contactArray[contactArray.length - 1]
  Logger.log(contactID)
  var contactName = aContact.getFullName()
  Logger.log(contactName)
  if (aContact.getCompanies().length > 0) {
    var companyName = aContact.getCompanies()[0].getCompanyName()
    }
  else {
    var companyName = ""
    }
  Logger.log(companyName)
  if (aContact.getEmails().length > 0){
    var emailAddress = aContact.getEmails()[0].getAddress()
  }
  else {
    var emailAddress = ""
  }
  Logger.log(emailAddress)
  var strMessage = 'Please review the contact information for ' + contactName + ' from ' +companyName +'.\n'
  strMessage += 'Send an email to: ' + emailAddress + '.\n'
  strMessage += 'Edit the contact https://www.google.com/contacts/#contact/' + contactID + ' ' + contactName + '.\n'
  strMessage += 'Search LinkedIn http://www.linkedin.com/search/fpsearch?type=people&keywords=' + encodeURI(contactName) + '.\n'
  strMessage += 'Search Facebook https://www.facebook.com/search/results.php?q=' + encodeURI(contactName) + '.\n'
  strMessage += 'Search Twitter https://twitter.com/search?q=' + encodeURI(contactName) + '.\n'
  
  Logger.log(strMessage);
  GmailApp.sendEmail(Session.getEffectiveUser().getEmail(), 'Review Contact - ' + contactName + ' from ' + companyName , strMessage);
//  UrlFetchApp.fetch("https://script.google.com/macros/s/AKfycbwG7J3xWQlljkIzkh_rOBhNPLAqriHvScwroIg1RFXYnWcJVd99/exec?scriptName=reviewContacts");
  RGLibrary.logScriptExecution('reviewContacts')
};

https://github.com/RossGoodman/GoogleAppsScript/blob/master/reviewContacts

The script picks a random number, selects the contact associated with that number and formats an email with actionable links embedded within it.

I then create a trigger to run this script once per day at lunch time, allowing me to review the contents whilst I’m having my lunch.

See also this post for a similar search but built into Microsoft Outlook.

Leave a Reply

Your email address will not be published. Required fields are marked *