Deleting Particular Mail From All Accounts
Appearance
Following script deletes a particular mail from all accounts. In the script, the subject of the mail is "Re: Annual Performance Appraisal Results: FY 2011-12" and the sender is "narinder.kalia@orientbell.com"
#!/bin/bash
for i in `cat userlist2`; do
addr=$i
echo ""
echo "Searching $addr"
#for msg in `zmmailbox -z -m "$addr" s -l 999 -t message "subject:$subject"|awk '{ if (NR!=1) {print}}' | grep -v -e Id -e "-" -e "^$" | awk '{ print $2 }'`
for msg in `zmmailbox -z -m "$addr" s -l 225 -t message 'subject:"Re: Annual Performance Appraisal Results: FY 2011-12" and From:narinder.kalia@orientbell.com' | awk '{ if (NR!=1) {print}}' | egrep -v 'Id|-----|^$" | awk '{ print $2 }'`
do
echo "Removing "$msg""
zmmailbox -z -m $i dm $msg
echo "Deleted from $i"
echo ""
done
# fi
done