Former Sun editor Rebekah Brooks sent a text message to Prime Minister David Cameron telling him "professionally we are all in this together", the Leveson Inquiry into press standards has heard.
In the message from the former News International chief executive - among a batch ordered by the inquiry to be handed over by NI - she also said she was "rooting for him" ahead of a major speech.
The text was read out by the inquiry's counsel Robert Jay QC as he grilled Mr Cameron about his close friendship with Mrs Brooks - questioning which the previously assured premier appeared more uncomfortable dealing with.
Sent on the eve of Mr Cameron's speech to the Conservative Party conference in 2009, and just days after The Sun switched its support to his party from Labour, it said: "I'm so rooting for you tomorrow not just as a proud friend but because professionally we are in this together. Speech of your life? Yes he Cam!"
Asked to explain the message, Mr Cameron said: "The Sun had made this decision to back the Conservatives, to part company with Labour.
"The Sun wanted to make sure it was helping the Conservative Party put its best foot forward with the policies we were announcing, the speech I was making. That's what that means."
He went on: "We were friends. But professionally, me as leader of the Conservative Party, her in newspapers, we were going to be pushing the same political agenda."
Mrs Brooks yesterday made her first appearance in court on charges of conspiring to pervert the course of justice over the phone hacking scandal.
Cameron had 1,404 meetings or interviews with the media during his four years and five months as Opposition leader.
That worked out at more than one every working day, Inquiry counsel Robert Jay QC said.
Once in Government the number averaged at 13 a month, a fall of 50%, he added.
Before entering No 10 the Conservative leader had ten meetings with Rupert Murdoch and 15 with James Murdoch.
He met Rebekah Brooks 19 times, although that number did not necessarily include social engagements, Mr Cameron said.
The Prime Minister denied suggestions any editor or proprietor had ever tried to pressure him into changing policies but said there would be "robust debates" on certain topics.
He told the Inquiry it was important not to "overdo" the influence wielded by newspapers.
"In no way does winning the support of this newspaper or that newspaper guarantee an election victory," he added.
Cameron tells Leveson that 24-hour news channels make life difficult
He admitted that it was difficult for governments to reform the system because they had a vested interest.
"We need to try to find a way for some independence to be brought to that," he said.
"I think the regulatory system we have at the moment doesn't work.
"We need to draw some boundaries but it is very difficult to do.
"If you take the expenses scandal, it was deeply painful for politicians but it was absolutely right that it was revealed."
He added: "In the last 20 years, I think the relationship has not been right. I think it has been too close and I think we need to get it on a better footing."
Mr Cameron told the inquiry that the advent of 24-hour news channels had made life more difficult for governments.
He said: "We are in a permanent battle of issues being thrown at you hour by hour where responses are demanded incredibly quickly.
"Politicians have to get out of the 24-hour news cycle to try to fight every hourly battle and face long-term issues and be prepared sometimes to take a hit on a story."
Mr Cameron said the relationship with the press was "not particularly trusting at the moment".
"I think a lot of politicians think the press always get it wrong," he said. "A lot of the press think politicians are in it for themselves - are not in it for the right reasons. It's become a bad relationship.
"The expenses scandal was a massive knock to Parliament and politicians' standing and politicians have to prove they are worthy of respect."
He was asked about meetings with newspapers.
He suggested that he targeted Conservative-supporting newspapers and added: "With all due respect to the Daily Mirror, there is only a certain amount of respect I am going to have."
Mr Cameron said broadcasting rules meant that television "could not be on your side".
He added: "A lot of the time when I was party leader was spent thinking how you could get your message our message across on television."
Mr Cameron told the inquiry: "This is, I think, a cathartic moment, when ... all the relationships that have not been right, we have a chance to reset them, and that is what we must do."
The Prime Minister said in his written evidence that he had "never traded or offered a position on policy in return for the support of any media outlet".
He pointed to "quite strong disagreements" he had with Rupert Murdoch over the BBC or the Daily Telegraph over planning laws as evidence of his independence.
He also defended his personal closeness to senior media figures.
"You have to take care when you have personal friendships. But I think that can be done and I like to think I've done that," he told the inquiry.
Mr Cameron said that while he accepted the need for media plurality rules, he felt it was the nature of individual titles that in large part determined their influence, not the size of the stable they were from.
"It is not necessarily the size of the newspaper group, it is the strength and the voice of the paper," he said, singling out the Daily Mail as an example.
It was "an incredibly powerful force in the nation's politics but that was "not related really to its market power, it is to do with the way it pushes its agenda".
He complained about sustained campaigns against politicians and policies saying that the "volume knob had has been turned up really high in our press".
"Sometimes that does no one any favours."
But he also suggested that political leaders were far more concerned about the evening television news bulletins than they were about newspaper headlines.
He said part of the blame for hacking and other issues getting out of control was the reluctance of the political class to step back from its ties with the media.
"The press want access, the politicians want coverage for what they are doing, so the two parts focus on that.
"When it was going wrong, what did not happen was the politicians and the press did not disengage and say 'we have a real problem here and we need to deal with this'."
On the question of whether it was possible to force a separation of fact and comment in newspapers, he was firm that it was a "forlorn hope" and not one that should be pursued.
"It's quite impractical," he said
Cameron's views on the media formed while working at Carlton
David Cameron has long-held views about media regulation in the UK formed when he worked for a major commercial broadcaster in the 1990s, he told the Leveson Inquiry into press standards today.
As he began his evidence under oath at the Royal Courts of Justice, the Prime Minister said his seven years as corporate affairs director at Carlton "was quite a formative period".
The Tory leader has submitted an 84-page witness statement and three exhibits to the inquiry and will be questioned about them in an all-day session.
Asked about his time in television before quitting for a political career, he said: "Carlton was quite a formative period.
"I formed a lot of views about the media then which I still hold today."
He said he also formed relations with many journalists at that time, though those with Westminster media were forged more in his previous role as a ministerial special adviser.
In that role, he said, he acted as both a "mouthpiece" for his home secretary and chancellor bosses and as a "sponge", meeting people the minister did not have time to see.
Asked if he ever gave his own opinions rather than representing those of the minister, he said: "On occasion, I am sure I would have made clear to people my own views about something."
Pressed on whether he would have made clear that he was not speaking the mind of his political boss, he replied: "I would hope so."
Mr Cameron is expected to use his appearance to set out new regulations concerning special advisers as part of the ministerial code of interests.
Culture Secretary Jeremy Hunt's aide Adam Smith was forced to resign after admitting that his contacts with News Corp representatives during the BSkyB takeover bid were too close.
Mr Cameron was asked about his general perspective on the media and his relationships with journalists.
He was asked about off the record discussions with journalists and said such contacts could help journalists "understand more about you".
Mr Cameron told the inquiry: "You want people to understand your motives, your character, your judgment, your views."
He said sometimes relationships were strong but "sometimes you struggle".
"Asking politicians whether they are happy with the way the media is reporting the news is ... a bit like asking farmers about the weather. We are always going to complain."
He said development in technology and the arrival of 24-hour news had changed the media industry.
"I think from the politician's point of view, particularly the Government's point of view, it is sometimes a change for the worse."
He said announcements could be "picked over" by 24-hour news and newspapers had to find something different.
But Mr Cameron added: "Politicians are always going to complain about this sort of thing. I would not put too much weight on it."
Mr Cameron told the inquiry: "What it led me towards is quite a lot of focus on broadcasting.
"If you really want to get through to somebody, television is an incredibly powerful medium.
"Television is extremely powerful and important, so it must not be left out of the mix."
Mr Cameron was asked about newspaper campaigns and said some were "extremely important and powerful".
He said the Daily Mail's campaign on the Lawrence trial was "extremely important" and he mentioned the Sarah's Law campaign.
Mr Cameron told inquiry chairman Lord Justice Leveson: "Sometimes I feel newspaper reporting, coverage, it feels like you are being shouted at rather than spoken to."