Pre processing code

Handles a lot of the output for the email notifications.