Foley was goaded into writing the IMs. I think he didn't know it was a prank and he really thought that he was chatting to a former page who was legitimately interested in him. The former page set him up. Regardless, Foley thought that he was chatting with an interested young man. He wasn't involved in the prank; he was the subject of the prank. Even if he was goaded by the young man, Foley is still guilty because he thought that he was having an inappropriate conversation with a minor.
How did the IMs' get from Edmund to ABCs' Brian Ross?