modified sendemailbydocid func's rule