Added logic to the email button controls