Ajamil was a sinner of no bound. In his death bed, he started yelling out his son's name which happened to be "Narayan". This act of Ajamil caused a confusion between Yamdoots and Vishnudoots. Yamadoots said that since Ajamil was a sinner, they have come to take him and Vishnudoots said that since he took name of Lord Narayan, they have come there to take him to Lord's Divine abode.
This story from Shreemad Bhagwatam is often misinterpreted.
People assume that simply by taking Lord's name, without actually thinking of Him, Ajamil went to Vaikunth. But, it is not so. In the lecture below, Shree Maharajji clearly illustrates the complete story of Ajamil, what happened to him after he heard the dialogue of Yamdoots and Vishnudoots and how he went to Vaikunth, later. Shree Maharajji also beautifully explains the importance of mann (mind) while chanting God's name.
Listen to the lecture here: