WASHINGTON (CNN) -- A federal judge has ordered the Bush White House to preserve its e-mails, just days before a new administration takes over.

A federal judge has ordered the White House to reserve all e-mail from March 2003 to October 2005.

The court's preservation notice Wednesday stems from an ongoing lawsuit by private groups over allegedly missing electronic messages, and allegations the White House failed to properly monitor its internal communications among staff.

It has been a thorny legal and political issue for outgoing Bush officials, who are in the process of transferring more than 300 million e-mail messages and 25,000 boxes of documents to the National Archives.

U.S. District Judge Henry Kennedy instructed officials to search all White House workstations "and to collect and preserve all e-mails sent or received between March 2003 and October 2005."

Executive office personnel were also ordered to surrender any e-mail from that 31-month period.

There was no immediate response from the White House, but officials said in the past they had succeeded in accounting for the electronic correspondence after much hard work.

The time period in question includes the start of the Iraq War, as well as the investigation into the leak of Valerie Plame Wilson's identity as a CIA operative. She is the wife of former diplomat Joseph Wilson, who publicly criticized the administration's justification for invading Iraq. The couple sued, claiming White House officials retaliated for his public stance by revealing her identity to reporters.

Groups who brought the lawsuit over the e-mails applauded the court order.

"There is nothing like a deadline to clarify the issues," said National Security Archive Director Tom Blanton. "In six days the Bush Executive Office of the President will be gone and without this order, their records may disappear with them. The White House will complain about the last-minute challenge, but this is a records crisis of the White House's own making."

The civil cases are Citizens for Responsibility and Ethics in Washington v. Executive Office of the President (07-1707) and National Security Archive v. Executive Office of the President (07-1577).

All About The White House • Valerie Plame • Iraq War