Isolated the email content rendering from the task function.