Edward J. Sadowski Jr., a Catholic deacon and former middle school teacher, pleaded guilty Friday to attempted statutory rape and multiple child-pornography charges in Middlesex Superior Court, Boston, and was sentenced to serve two years in prison.

Sadowski, 59, of 452 Shady Valley Rd., pleaded guilty to one count each of attempting to entice a minor to pose nude, to pose in a state of sexual conduct, and three counts of attempting to disseminate material harmful to minors.

He faces similar child-pornography charges in Rhode Island Family Court, where he is scheduled for a pretrial conference on Thursday.

In the Massachusetts case, Sadowski was sentenced to serve five years of probation after his release from prison.

His arrest came after a two-week undercover investigation into the online exploitation of minors. Sadowski corresponded online with a Massachusetts state trooper, believing the officer was a 14-year-old girl.

Sadowski sent the trooper pornographic images, including nude photos of himself, and arranged a meeting at the Super 8 Motel in Watertown, Mass. Investigators said he planned to photograph the minor and have sex with her.

When the police arrested Sadowski at the motel on July 26, he had a digital camera with him. The Rhode Island State Police searched his house later that day and seized 14 pornographic photographs of minors stored on Sadowski's computer.

The Coventry police also aided the investigation, which was primarily conducted by the High Tech and Computer Crimes Division of the Massachusetts attorney general's office.

After Sadowski's arrest, the Roman Catholic Diocese of Providence suspended him from his role as a lay deacon at St. Vincent de Paul Church.