You can setup a macro if you purchase the program "Keyboard maestro".
It will create a command that is executed by a trigger.
The command would be to open (in your example) to launch mail.app, and the trigger can be set to the Launch of the Safari.app application.
This is the only way I can think of doing it, perhaps there are some free Macro apps out there to help you with this. Alternatively, maybe there is an applescript to do it.