fix document query
apply the new changes

1、send email
2、global variable