The man had publicly denied all criminal actions for nine months, claiming he was innocent in judicial proceedings in the western province of Värmland. But his text and Facebook messages said otherwise.
"I want you to know that I am sincerely sorry and I beg for forgiveness in every way I can," the 25-year-old man wrote to the woman on Facebook.
The Karlstad District Court ruled that his messages were sufficient evidence that he had assaulted the woman and sentenced the man to six months in prison for rape.
A young woman reported the man to police in February after reportedly waking up to find he had his fingers inside her. The two had been at a party where many guests stayed the night, but the man said it was “too crowded” at the apartment and went home with the woman instead. She left him to sleep on the couch and went to bed, but after she fell asleep the man entered her room and began the assault.
"I feel so bloody rotten," the man wrote in another message.
The court also ordered the man to pay damages of 30,000 kronor ($4,525) to the woman, reported the Värmlands Folkblad newspaper.