A week before Election Day, Democrats have taken legal action to try to stop thousands of unsolicited text messages encouraging people in Northern Virginia to vote against their candidates.

A lawyer for the Democratic Party of Virginia wrote to ­ccAdvertising, a political phone and text-messaging vendor with a history of sending unsolicited messages, whose chief operating officer, Republican Jason Flanary, is running for Senate in Fairfax County. And a local Democratic activist, Ruth Miller, filed a lawsuit in Fairfax County General District Court on Monday.

Others who received texts have contacted the office of Attorney General Ken Cuccinelli II (R), the Virginia Department of Agriculture and Consumer Services, and the Federal Communications Commission.

The texts have been reported in several Senate districts, including that of Flanary’s opponent, Sen. David W. Marsden, as well as Sen. George L. Barker, Sen. Linda T. “Toddy” Puller and Sen. Janet D. Howell, all Fairfax Democrats.

“When people resort to illegal or unethical tactics, it’s obviously despicable,’’ said Barker, who is facing Republican Miller Baker. “It undermines the entire process and integrity of the system.”

The messages do not identify a sender, but the state party, Marsden and others believe that ccAdvertising is behind the texts. The company did not return a call for comment.

But Brian Coy, spokesman for the Democratic Party, said a ­ccAdvertising lawyer told the party that the company did not admit to sending the texts.

FreeEats, the parent company of ccAdvertising, has been fined for similar conduct in North Dakota, according to news reports. Americans in Contact political action committee, which lists Flanary as executive director, has been tied to unsolicited messages in other states, including North Carolina, Illinois and Pennsylvania, according to published reports.

Both companies have given in-kind services to Flanary’s campaign, according to the Virginia Public Access Project, a nonpartisan tracker of money in politics. Many other Republicans in Virginia also employ ccAdvertising.

“Given your company’s past use of technology for this exact purpose and your stake in Mr. Flanary’s race both as a service provider and employer, there is obviously strong reason to believe that ccAdvertising is the entity that has transmitted these unsolicited text messages,’’ the Democratic party’s lawyer wrote in a letter to the company.

Flanary, a former vice president of government relations for the Fairfax Chamber of Commerce, did not return a call for comment Monday.

“It’s pretty clear this is what my opponent does for a living,’’ Marsden said. “It’s pretty consistent with the research we have done on him.”

In the final days of the campaign, attacks by Republicans and Democrats are rampant.

Republicans are fighting to gain control of the Virginia Senate next week as they try to take the last bastion of Democratic power in Richmond.

Democrats are accusing Republicans of trying to “scare” voters with the text messages, which began more than a week ago, as they try to win two seats to seize control of the Senate.

Dave Rexrode, executive director of the Republican Party of Virginia, said he had no knowledge of the texts.

One text message says: “OBAMA and his VA DEMOCRAT allies want to RAISE YOUR TAXES. Send a message. DO NOT vote for VA Democrats on 11/08/11.”

Republicans across the state have been trying to tie Democrats to an increasingly unpopular President Obama in recent weeks in speeches, campaign mailers and TV ads.

A second text message singled out Marsden: “Dave Marsden voted to allow Ffx County Schools to HIDE FROM PARENTS when they discipline kids. Ask Dave why.’’ It listed his campaign’s phone number.

Marsden said he voted against a bill this year that would have required schools to tell parents if their children had been disciplined, but he said he supported the concept. He said it was not clear how the school districts were supposed to notify the parents, and he wanted to work further on the bill with its sponsor, Del. Kaye Kory (D-Fairfax).

Marsden’s campaign said it has received about 250 responses to the text messages. Another dozen complaints went to the Democratic party.

Cuccinelli spokesman Brian Gottstein said that the attorney general’s office does not comment on its investigations but that it would investigate if it received a request from the State Board of Elections. A spokeswoman for the Board of Elections did not respond to a request for comment.

The Virginia Department of Agriculture and Consumer Services is referring people to the FCC, a spokeswoman said.

Dave Mills, executive director of the state Democratic Party, said he believes the texts violate federal law that bans unwanted communication sent to wireless devices.

Miller, a lawyer who is active in Democratic politics in Fairfax, filed a complaint with the FCC and sued in General District Court, where she believes she can receive $500 to $1,500 per unwanted message. “It seems pretty straightforward,’’ she said.