implement analyze and sendemail functions