A medical student killed himself after friends from his university rugby team shared WhatsApp messages he sent about a college romance, an inquest in Wales has heard.

Edward Senior, 22, told teammates about a “brief relationship” with a fellow student at Swansea University and they shared the messages on social media with hundreds of other students as a prank.

University officials investigated the incident and then suspended Senior, which he feared would end his hopes of practising medicine.

After returning to his family home in Raglan, Monmouthshire, he was found dead in woodland in February.

Wendy James, the coroner, told the inquest at Newport, Gwent, that Senior’s death highlighted the risks of putting “sensitive and private” messages on the internet.

“He made the post in a private form and that post was shared by friends with the consequences that he was excluded from the majority of lectures,” she said. “He felt his future as a doctor was in jeopardy. He would have moved on and gone on to be a marvellous doctor and a credit to his friends and family.”

The inquest heard that a complaint was made about the social media post, the details of which were not disclosed, and the medical student was excluded from lectures and organising charity events.

The coroner continued: “This had a profound effect on his wellbeing. He returned to the family home.”

He left a note, which indicated that he felt worried and alone after his exclusion. “Despite having the support of a loving family, it was not enough for him to get through a stressful period in his life,” the coroner said.

“Not knowing what the ramifications would be, he felt isolated and became overwhelmed. It is not unusual for young people to make mistakes. But his biggest mistake was dwelling on that one mistake.”