Abu Dawud Book 33, Hadith Number 4457.
Narated By Some Companions : AbuUmamah ibn Sahl ibn Hunayf said that some companions of the Apostle of Allah (PBUH) told that one of their men suffered so much from some illness that he pined away until he was skin and bone (i.e. only a skeleton). A slave-girl of someone visited him, and he was cheered by her and had unlawful intercourse with her. When his people came to visit the patient, he told them about it.
He said: Ask the Apostle of Allah (PBUH) about the legal verdict for me, for I have had unlawful intercourse with a slave-girl who visited me.
So they mentioned it to the Apostle of Allah (PBUH) saying: We have never seen anyone (so weak) from illness as he is. If we bring him to you, his bones will disintegrate. He is only skin and bone. So the Apostle of Allah (PBUH) commanded them to take one hundred twigs and strike him once.