Added core of email script