A SEX offender was caught messaging a ‘child’ in an undercover police sting.

Ashley Mark Yard, 38, thought he was messaging a 13-year-old girl called Holly.

He sent a picture of himself and made various sexual references between April 6 and April 8 last year.

Yard was in fact communicating with a police officer who was pretending to be the teenage girl.

Judge Stephen Climie said it was “good fortune rather than design” that no actual child suffered harm as a result of Yard’s “serious” offending.

Yard previously pleaded guilty to attempting to engage in sexual communication with a child. He appeared in the dock for sentencing on Tuesday, May 10.

Prosecuting, Hannah Williams said the defendant started messaging the ‘girl’ online. The undercover officer wrote in messages that Holly was 13 years old and from Derby.

Ms Williams said the conversation continued with Yard writing that “he wants a long-term relationship” and asking her about what she was wearing.

The communication moved to WhatsApp, where the defendant made references to sexual behaviour and whether the girl would like it.

Officers attended an address in Poole where he was staying at the time in June last year. He identified himself and he was arrested.

In interview, Yard made full admissions and expressed his remorse, Ms Williams said.

The court heard the defendant was jailed for 18 months in 2010 for a series of convictions relating to making and distributing indecent images of children in 2007 and 2008.

Mitigating, Amber Athill said her client “appreciates the seriousness of the offence”, adding that he was “extremely anxious” ahead of the sentencing hearing.

She described the offence as a “momentary slip up when he was using cocaine heavily”.

Ms Athill said the drug use made him act “impulsively” and he “forgot all he had learned and all he had achieved in those 14 years” since his previous criminality.

The defendant was “disgusted and ashamed” after reading the conversations at a later date.

The court heard the offence carried a maximum sentence of two years.

Judge Climie said the appropriate starting point was 15 months’ imprisonment before any reduction due to his guilty plea at an early stage.

He decided against handing the defendant a custodial sentence. He said Yard would have only served a short time behind bars and then not be under supervision.

“The public would be concerned for the future as am I,” said Judge Climie.

After hearing of the defendant’s compliance with the previous 10-year sexual harm prevention order, was made subject to a new indefinite order, which will likely run for the rest of his life.

The judge sentenced Yard, of Cocklands, Charminster, to a three-year community order, which kept him under the “court and probation service’s control for the next three years”.

The defendant was placed on the sex offenders register for 10 years.