sending variable value via mailx

Hi all,
I need to send a variable value in the script through mailx. Please find the script below but its not working.

agents.sh:

agents=`grep "Tot Agents " snapshot.dbm`
if (( $? == 0 )); then
   mailx abc@gmail.com $agents
fi

Hi.

Something like:

agents=$(grep "Tot Agents " snapshot.dbm)
if [ $? -eq 0 ]; then
   echo "$agents" | mailx abc@gmail.com
fi

Its working. Thanks alot.

if you want to have the variable in the subject:

echo | mailx -s "this is my $VARIABLE" your@email.com