Added profile parameter to email()

Reworked profiles to be more generic, so that they are flexible enough to be used in other circumstances, not just SQL profiles.