A 51-year-old Queens man was in for a surprise after he allegedly attempted to meet a 14-year-old girl for sex last week but was met instead by police officers.

Joseph Sylvester of Middle Village is facing charges of second-degree attempted rape, second-degree attempted criminal sexual act, first-degree attempted disseminating indecent material to minors and attempted endangering the welfare of a child.

RELATED: Bronx cop arrested for alleged sexual relationship with teen girl

According to prosecutors, on Nov. 23, 2015 at about 10:52 p.m. an NYPD vice detective — who was undercover online acting as a minor — received an instant message from Sylvester, who was using the screen name ARMYSTRONGNY@AOL.COM.

Sylvester allegedly identified himself as a 50-year-old who wanted to chat and the detective then wrote back that “she” was a 14-year-old girl from Queens, authorities said. The two exchanged photos, upon Sylvester’s request, and the male detective provided a photo of a female undercover officer. That same day the messaging continued until after midnight and were of sexual nature.

At the end of the conversation, the detective gave Sylvester his undercover phone number and shortly after received a text message, which said “it was Joe from AOL,” according to prosecutors.

Then from between Nov. 24, 2015 to Jan. 5, Sylvester started and sent sexually-explicit instant message, using the same screen name, on several occasions, according to the charges. After the first message, he also expressed the desire to see the teen girl.

RELATED: Queens P.E. teacher accused of raping teen student at public high school

Sylvester was then arrested at a pre-arranged location in Queens after he met with the female undercover officer, whose photo had been initially sent to him.

He also allegedly made statements to police saying that he had been sending instant message on AOL with other underage girls.

“This case underscores the crucial importance of Internet surveillance initiative by law enforcement to protect children from sexual predators and should serve as a warning to parents to closely monitor their children’s Internet access and activities,” Queens District Attorney Richard A. Brown said. “Despite numerous publicized arrests for exactly this type of alleged behavior, sexual predators continue to be relentless in searching the Internet for victims. Do not let your child become one of them.”

Brown added that any parent whose child had spoken with Sylvester through his email address and has concerns or suspicions, is encouraged to call the Queens district attorney’s office at 718-286-6590.

If convicted, Sylvester faces up to four years in prison and would be required to register as a sex offender.