added auto send mail
fixed some query related bugs
Merge branch 'TK-01910-send-mail'