The collapse of the impressive career of CIA Director David H. Petraeus was triggered when a woman with whom he was having an affair sent threatening e-mails to another woman close to him, according to three senior law enforcement officials with knowledge of the episode.