Phone-hacking also uncovered a claim that Prince Harry had broken rules at military training academy Sandhurst by asking an aide for help with an essay, a court heard today.
Prosecutor Andrew Edis QC told jurors at the Old Bailey that a story in the News of the World came from a voicemail that was illegally accessed by private investigator Glenn Mulcaire on behalf of the tabloid's former royal editor Clive Goodman.
It is claimed that the then editor Andy Coulson was also aware of what was happening.
Edis said the story, published on 18 December, 2005, was one of a number of stories cited by Goodman as he tried to justify paying Mulcaire a weekly retainer.
The prosecutor said the story, which ran under the headline "Harry's aide helps out on Sandhurst exams", had "got into the paper and was based entirely on a voicemail."
The court heard that Coulson stopped weekly payments to Mulcaire in February 2006, and on the same day Goodman emailed him justifying them in a bid to keep them going.
Referring to Mulcaire only as "matey", the royal editor said he was a valuable source of stories on the royal family, especially after William started at Sandhurst.
He wrote: "We are the only paper getting any information out of there at all about his movements and Kate's."
The court heard that one version of the message, handed to Harbottle and Lewis, ended there, but another version, downloaded by Goodman after he was charged in 2006 and also obtained from the News International system, went on: "There have been several close calls that could have made us some great pics.
"We were five minutes away from catching Kate and William together last Saturday."
Edis said that although seeing the now-married couple together would not be unusual nowadays, at the time there was interest in it.
The court heard Goodman (pictured above) told Coulson: "This sort of information is not manageable on a story by story basis", as he described that there were costs of setting up and maintaining surveillance and said Mulcaire was not a "hack" and did not understand what was or was not a story.
Justifying the payments, Goodman wrote: "It's safe, productive and cost effective and I am confident it will become a big story goldmine for us if we let it run a bit longer."
Edis read a transcript of a voicemail message left by Prince Harry on his private secretary Jamie Lowther-Pinkerton's mobile phone.
According to the message, Harry was seeking information on an essay he had to write on the Iranian embassy siege from the former SAS man.
He said: "Because I need to write an essay quite quickly on that but I need some extra info.
"Please, please email it to me or text me."
Edis said the NoW was interested in the story to show some sort of misconduct.
The court heard there were discussions between Goodman and Coulson about how to run the story, which they knew was "100% fact", without exposing its source.
They decided not to refer to the siege as it would be "too precise to get through unnoticed", the court heard.
Edis said: "It means that if they say that what he was asking about was information about the Iranian Embassy siege, everyone would know that they hacked his voicemail because obviously Harry and Jamie Lowther-Pinkerton both knew that this voicemail was sent and received."
The tabloid also obtained information about Prince William getting "shot" during a training exercise in Aldershot, jurors were told.
Edis read from a voicemail message from January 2006: "William found himself in the wrong place during a night exercise so he got shot, pretend shot.
"There is a voicemail, recording of a voicemail, in which Prince William says something about that. So it's a phone hack."
All defendants deny the charges.
The trial continues.