Categories
Productivity Technology

Contacts – Keep In Touch or Update Details

One of my New Year resolutions was to keep in touch with more people.

I also need to clear out my contact list as there are lots of “old” and incomplete entries in my Google contacts list.

Ever the productivity geek I wanted to automate this. I ended up writing the following Google Apps Script:

Select a random contact and then send myself an email prompting me to contact the person, edit their details and look them up on LinkedIn. This is then scheduled to run once a day:

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) + ‘.’

Logger.log(strMessage);
GmailApp.sendEmail(‘Me@MyDomain.com’, ‘Review Contact – ‘ + contactName + ‘ from ‘ + companyName , strMessage)
};

Please NOTE:

  • Any Quotes in the script should be delete and re-typed as the editor replaces them with “smart” quotes.
  • This is not very performant – I’m just learning the Google APIs.
  • This is not very “good” – I have never claimed to be a JavaScript programmer !

If you have any suggestions for improvements to this code, let me know in the comments.

Leave a Reply

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