sending query results via email
You need to invoke hook_mail() to specify a 'body' parameter. It is a little confusing since it is two steps but well documented: http://api.drupal.org/api/drupal/includes%21mail.inc/function/drupal_mail/6

See 'example_notify()' and 'example_mail()' from the above link.

In your case yo need to call drupal_mail outside of your invocation of hook_mail. See below for an example. You can pass the body as in the $param when you call drupal_mail or you can edit it when you invoke hook_mail.

Be advised that this is not the best example since it would fire off an email any time somone visited that page, but I'm not sure where you are trying to call drupal_mail from:

$query = "
SELECT uid
FROM users
JOIN users_roles ON users.uid = users_roles.uid
WHERE mail NOT LIKE '%@mail.com' 
AND users_roles.rid =6
AND users.status =0
";


 // get the links (no range limit here)
  $queryResult =  db_query($query);
  while ($links = db_fetch_object($queryResult)) {
    $account = user_load($links-&gt;uid);
    $body = t('Message for %name', array('%name' =&gt; $links-&gt;name));
    $subject = t('New email!');
    $params = array('body' =&gt; $body, 'subject' =&gt; $subject);
    drupal_mail('customstats', 'html_mail', $account-&gt;mail, user_preferred_language($account), $params);  
    $page_content .= l($account-&gt;name, 'mailto:'.$account-&gt;mail) . '&lt;br /&gt;';
   }


  if ($page_content == '') {
    $page_content = "No existe información para mostrar.";
  }

  return $page_content;
}