setEmailHelper

What does this program do?

This program's primary function is quite simple: to provide a scriptable method of setting a user's default email program. This program can be used from a Unix shell, AppleScript, or Python script, just to name a few.

A secondary function is provide a way of changing the default email program without having to set up a dummy account in Mail. This is quite annoying if you need to start up Mail just to change the email helper preference.

What can I use it for?

The first thing to know is what this setting does. Most programs do not have their own, built-in, email functions. But if you click on a mailto link in the Firefox web browser, for instance, it uses the "email helper" helper setting to determine which program is the default email program, and then Firefox passes on the request to that program to open the new email. A user selecting "Send Email" next to a contact's email address in Address Book would be another good example.

Not too long ago, the Mac OS allowed you to change the default email program in the System Preferences. But in version 10.3 (Panther) of the Mac OS, Apple removed the ability to set the default email program from the System Preferences. Instead, they moved the GUI for this into their email program, Mail. This is all fine and well if you are going to use Apple's Mail anyway, but if you are using any other program it can create some tiresome situations, especially if need to do this on multiple machines!

How do I use it?

From the command line or a shell script this is quite easy. The example here assumes that we are going to use it from the command line, and that setEmailHelper is in the current directory:

G4x2% ./setEmailHelper -c 'OPIM' -n 'Microsoft Entourage'

Mailto helper set to the creator code "OPIM"
G4x2%

As you can see, setEmailHelper reports back on what the result was. If you enter an incorrect creator code, you were trying to set it to a creator code for a program that is not installed, or there is a problem with the type/creator code database on the system setEmailHelper was run on, it setEmailHelper probably won't give an error (unfortunately). Instead, the creator code given in the reply will be whatever it was prior to calling (i.e., not the one you gave it).

G4x2% ./setEmailHelper -c 'xxxx' -n 'Mail.app'

Mailto helper set to the creator code "OPIM"
G4x2%

One thing that definitely won't give an error is if you use the wrong application name. I don't know if there is even any point to supplying this value in Panther, but it is still required by the InternetConfig routine ICSetPref.

If you want to call setEmailHelper from AppleScript, there is a little bit of extra work required. The following is an AppleScript handler that will set the default email program to Apple's Mail. This example assumes that the global variable gPath has previously been set to the POSIX (i.e., the Unix style) path where the setEmailHelper can be found.

on setDefaultEmailerToMail()
      -- Add single quotes around the path in case it includes a space.
      do shell script "'" & gPath & "'" & "setEmailHelper -c 'emal' -n 'Mail.app'"
end setDefaultEmailerToMail

What is the Creator Code and application name that you need to use? Depends on which program you want to use as your default. Here is a short list:

Code App Names Version
----  ---------------------  ------- 
emal Mail.app 1.3
OPIM Microsoft Entourage 11.0
CSOm Eudora 6.0
FCui FirstClass 8.0

What are the requirements for this program?

This program has been tested on 10.2.8, 10.3.7, and 10.3.9.

The program that you want to set as the email helper must already be installed.

You may need to turn on execute permissions for the file, if these somehow get turned off while moving setEmailHelper around. To enable the owner and group to execute enter the following at the Terminal command line:

chmod ug+x setEmailHelper

DISCLAIMER: Although this is a fairly trivial piece of code, my C programming skills are pretty rusty, so you are using this program entirely at your own risk!.

Download setEmailHelper