President Donald Trump on Tuesday sent House Speaker Nancy Pelosi a raging, six-page letter in which he tore into the impeachment process currently underway, calling it an "illegal, partisan attempted coup."

The letter came as the House gears up to vote this week on whether to make Trump only the third president in American history to be formally impeached.

"By proceeding with your invalid impeachment, you are violating your oaths of office, you are breaking your allegiance to the Constitution, and you are declaring open war on American Democracy," the president said in his letter.

"You are the ones interfering in America's elections. You are the ones subverting America's Democracy. You are the ones Obstructing Justice," Trump wrote to the California Democrat. "You are the ones bringing pain and suffering to our Republic for your own selfish, personal, political, and partisan gain."

Trump is expected to be formally impeached on two separate articles: abuse of power and obstruction of Congress, both of which Democrats argue violate Trump's oath of office and his pledge to uphold the Constitution. The House is expected to vote on impeachment Wednesday.

In its mixture of incredulity, outrage and defiance, the letter echoed many of Trump's tweets. "After three years of unfair and unwarranted investigations, 45 million dollars spent, 18 angry Democrat prosecutors, the entire force of the FBI, headed by leadership now proven to be totally incompetent and corrupt, you have found NOTHING!" Trump wrote.

"Few people in high position could have endured or passed the test. You do not know, nor do you care, the great damage and hurt you have inflicted upon wonderful and loving members of my family," he continued.

A representative from Pelosi's office did not immediately respond to questions from CNBC about her reaction to the document.

Trump appeared to acknowledge that the letter would have no formal effect on this week's House vote, but said he wanted his objections to be part of the trove of documents the impeachment will undoubtedly produce.

"I write this letter to you for the purpose of history and to put my thoughts on a permanent and indelible record," Trump said.

The president's missive also served to codify and formalize a wide range of protestations that Trump and House Republicans have worked to hone over the past three months, as the Democratic-controlled House conducted an impeachment inquiry into Trump.

The purpose of the impeachment probe has been to determine whether the president abused his power by mounting a monthslong pressure campaign on the government of Ukraine, in order to force the war-torn U.S. ally to announce investigations into Trump's political opponents.

The campaign included Trump's alleged conditioning of a coveted White House visit for Ukraine's newly elected president, as well as nearly $400 million in U.S. aid to the country, on its willingness to launch two investigations, one into the son of former Vice President Joe Biden, and another into a discredited conspiracy theory that Ukraine interfered in the 2016 U.S. presidential election.

Provided the House approves the articles of impeachment, the proceedings will move to the Republican controlled Senate for a formal trial of the president, starting in the new year.

Senate Majority Leader Mitch McConnell, R-Ky., has signaled that members of Trump's party will support him and vote to acquit him of the charges, thereby preventing the president's removal from office.

Read the entire letter, below.