"Obviously at the time I wrote this, I was in a great deal of anguish as you can tell from the letter," she said.
"I do not know if anyone has been in this situation in a time of hurt, at night after a few glasses of wine, you probably shouldn't get on your computer.
"But that is obviously what I did. I wrote my feelings down in the moment, these are my thoughts really to myself but I wrote it in a letter form, probably with the intention of finishing it and sending it, but I probably thought better about it the next day."
Questioned by her barrister, Jonathan Laidlaw QC, about her life and career, Brooks explained how she had met Kemp, an actor on the BBC's EastEnders soap opera, in 1995 and they became engaged a year later. They split for a while but reconciled in 1998, deciding to marry and try for a family.
As Brooks spoke of her desire for children, she became emotional and briefly left the witness box. When she returned she said that she had undergone fertility tests in 2001 and 2002, but the marriage eventually faltered.
"I am sure if Ross was here he would say the same: our whole relationship was a bit of a rollercoaster. Sometimes it was very good and sometimes it wasn't," she said. "I think we were both working incredibly long hours, as you can see, in completely different industries and the war in Iraq started pretty soon after I became editor [of the Sun]."
She said the paper was producing 5am editions as a result in 2003 and all the senior staff moved into a hotel next to the office to live. "I stopped the early fertility tests and basically everything was put on hold."
She and Coulson had first become intimate in 1998, again for a period between 2003 and 2005 and briefly in 2006, she said.
But Brooks insisted that it had not been a six-year continuous affair. "Andy and I were incredibly close during that time. He was my best friend. It certainly complicated the friendship," she said.
"I think any affair is, by its very nature, quite dysfunctional and I think it certainly added a complexity to what was a very close friendship."
She had met her present husband, Charlie Brooks, the racehorse trainer, in 2007 and the pair quickly became close.
She said: "Everyone now knows my personal life was a car crash for many years. When Charlie and I met I think it's fair to say we knew very quickly that we wanted to be together and I told Charlie obviously about the fertility treatments in the past and said that if we did get together and he wanted children, I probably wasn't the right person.
"And anyway we overcame that and he said he wanted to get married anyway." They were advised to consider surrogacy. She and her cousin had been very close as children and she offered out of the blue to be a surrogate.
Brooks denies conspiracy to intercept communications, conspiracy to commit misconduct in public office and conspiracy to pervert the course of justice. Six others face a range of charges, all of which are denied. The trial continues.