trigger CheckDupeEmails on Contact (before insert, before update) { Map contactMap = new Map(); for (Contact Contact:System.Trigger.new) { if ((Contact.Email != null) && (System.Trigger.isInsert || Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email)) { if (contactMap.containsKey(Contact.Email)) { Contact.Email.addError('Another new Contact has the same email address.'); } else { contactMap.put(Contact.Email, Contact); } } } for (Contact contact : [SELECT Email FROM Contact WHERE Email IN :contactMap.KeySet()]) { Contact newContact = contactMap.get(Contact.Email); newContact.Email.addError('A Contact with this email address already exists'); } }