How to become a Yamaduta
"Those who have passed several years in the dreadful hell and have no descendants (to offer gifts) in their favor become messengers of Yama." (Garuda Purana 2.18.34)
Avoiding Yamaraja: Ajamila's story
Ajamila's story is given in the Bhagavata Purana (6th book, chapter 1) as an example to illustrate that even the most wicked person can attain Visnupada (salvation).Ajamila was a brahmana who was once sent by his father to the jungle to fetch samit (leaves and twigs to make the sacrificial fire). Ajamila met there a beautiful sudra woman. Forgetting everything, the brahmana made her his wife and children were born to them. When that brahmana, who was the very embodiment of all vices, reached the age of eighty-seven, the time came for him to die. Yamadutas (agents of Yama, the god of death) had arrived. The frightened Ajamila shouted loudly the name of his eldest son, "Narayana". Hearing the repeated call of his name "Narayana", servants of Visnu appeared there and dismissed the agents of Yama. From that day Ajamila became a devotee of Visnu and did penance on the bank of the Ganges and after some years attained salvation.
Ajamila was saved from hell because he chanted "Narayana" as the Yamadutas approached him. Afterwards Yamaraja forbade his servants from touching devotees who "even if by mistake or because of bewilderment or illusion... sometimes commit sinful acts," because "they are protected from sinful reactions because they always chant the Hare Krsna mantra."
Yamaraja then told the Yamadutas:
"Paramahamsas are exalted persons who have no taste for material enjoyment and who drink the honey of the Lord's lotus feet. My dear servants, bring to me for punishment only persons who are averse to the taste of that honey, who do not associate with paramahamsas and who are attached to family life and worldly enjoyment, which form the path to hell."My dear servants, please bring to me only those sinful persons who do not use their tongues to chant the holy name and qualities of Krsna, whose hearts do not remember the lotus feet of Krsna even once, and whose heads do not bow down even once before Lord Krsna. Send me those who do not perform their duties toward Visnu, which are the only duties in human life. Please bring me all such fools and rascals."