Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A former uniformed Secret Service officer was sentenced to 20 years in prison on Thursday for sending sexually explicit photos of himself to underage girls — while he was on duty at the White House.

Lee Robert Moore, 38, of Church Hill, Maryland, pleaded guilty in March to enticement of a minor to engage in sexual activity and attempting to transfer obscene materials to a minor. The Secret Service fired him after his arrest in November 2015.

At the time of his arrest, Moore was assigned to protect the White House complex, and prosecutors said he sent some of the materials while on guard duty at the White House.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Lee Robert Moore in a booking photo. Delaware Justice Department via AP

Moore was nabbed in an undercover sting when he sent indecent materials, including a picture of himself, to someone he thought was a teenage girl on the mobile apps Kik and Meet24, according to the criminal complaint. The "girl" turned out to be an agent of the Delaware State Police working with the Delaware Child Predator Task Force.

After his arrest, investigators learned that Moore had sent sexually explicit messages and images of himself to real underage girls in Florida, Texas and Missouri, according to the complaint.

Moore's case was heard in U.S. District Court in Palm Beach County, Florida, so he could consolidate his guilty pleas.

Moore's wife urged U.S. District Judge Daniel T.K. Hurley in court documents to sentence her husband, a retired Marine and father of two children, to the minimum sentence of 10 years.

"I can honestly say he is still a genuinely good and decent person," she wrote. "I ask that you consider the lowest possible sentence as it would greatly benefit our children, as well as myself."

But prosecutors asked Hurley to sentence Moore to life in prison, writing in court documents: "It is particularly galling that he was himself an armed guard at the single most important residence in our constitutional republic, yet he repeatedly used that guard booth to take photos of his penis and send them to underage girls."

Moore must also register as a sex offender and undergo sex offender treatment. Once he is released, he must remain under court supervision for the rest of his life.