Mishkat al-Masabih 4530
‘Auf b. Malik al-Ashja‘i said:
In the pre-Islamic period we used to apply spells, and we asked God’s messenger how he looked upon that. He replied, “Submit your spells to me. There is no harm in spells so long as they involve no polytheism.” 

Muslim transmitted it.
وَعَن عوفِ بن مَالك الْأَشْجَعِيّ قَالَ: كُنَّا نَرْقِي فِي الْجَاهِلِيَّةِ فَقُلْنَا: يَا رَسُولَ اللَّهِ كَيْفَ تَرَى فِي ذَلِكَ؟ فَقَالَ: «اعْرِضُوا عَلَيَّ رُقَاكُمْ لَا بَأْسَ بِالرُّقَى مَا لم يكن فِيهِ شرك» . رَوَاهُ مُسلم