Default Task Type to Email when sending an email

One question I hear over and over again, is why is the task type when I am sending an email in Salesforce not defaulted to Email? This is becomes an issue when you want to do reporting on all your tasks and they are logged as your default task type which generally is "Call".

I have written an Apex Trigger you can use to overwrite the Task Type and set it to "Email" when you are sending out an email from Salesforce. The trigger will look for "Email:" in the subject and also look for "Additional to:" as the first part of the description.

trigger SetTaskType on Task (before insert) {
For (Task {
String subject = nc.Subject;
String description = nc.Description;

if ( subject != null && subject.startsWith('Email:') && description.startsWith('Additional To:')) {
nc.Type = 'Email';
October 30, 2009