Donald Bain holds two versions of the cover of his ghostwritten autobiography of actress Veronica Lake in 2004. (GREGORY BULL/Associated Press)

Donald Bain, a little-known but versatile writer who sold millions of books, most of them published under other people’s names, died Oct. 21 at a hospital in White Plains, N.Y. He was 82.

The cause was congestive heart failure, said his literary agent, Bob Diforio.

Considered one of the pre-eminent ghost writers in the publishing world, Mr. Bain wrote more than 100 books, including most of the best-selling “Capital Crime” mystery novels of Margaret Truman.

Mr. Bain was also responsible for more than 40 titles in the "Murder, She Wrote" series, writing as Jessica Fletcher, the fictional mystery author and small-town sleuth portrayed in the long-running CBS crime drama by Angela Lansbury.

The “Murder, She Wrote” television series ran from 1984 to 1996, with Lansbury’s character solving murders in Cabot Cove, Maine, which, for all its New England charm, had an alarmingly high rate of violent crime.

Donald Bain, a ghost writer of fiction and nonfiction. (Martin Lederhandler/Associated Press)

Consciously written in the voice of Lansbury-as-Fletcher, Mr. Bain’s book series began in 1989 with “Gin and Daggers” and continued through last year’s “Design for Murder.”

In the books, Mr. Bain often had Fletcher leaving the comforts of Cabot Cove to solve crimes all over the world. More than 5 million books in the “Murder, She Wrote” franchise have been sold.

Mr. Bain’s first major success came in 1967, when he wrote the pseudonymous best seller “Coffee, Tea or Me?,” a risqué novel purporting to be a nonfiction account of the amorous adventures of two free-spirited flight attendants, or “stewardesses,” as they were then called.

The title derived from a salacious come-hither line delivered by one of the stewardesses, and it became a commonplace, if leering, catchphrase of the time. The novel sold millions of copies, prompting Mr. Bain to publish three more “Coffee, Tea or Me?” sequels, all written by “Trudy Baker” and “Rachel Jones.” The publisher hired two former flight attendants to portray the would-be authors on talk shows.

“It was magic,” Mr. Bain told Newsday in 1989. “They sold for 17 years. It was like having an annuity all those years.”

He went on to write a series of suggestive spinoff books about teachers, nurses, secretaries and other young working women.

Mr. Bain, a onetime broadcaster and part-time jazz musician, began working as a pen-for-hire in the early 1960s and quickly built a lucrative, if anonymous, business.

Although he did publish several books on history and other subjects under his own name, Mr. Bain spent most of his career writing novels, speeches, detective stories and frothy sex romps under assumed names — or the famous name of someone else.

“My strength is like an impressionist or mimic in a nightclub — I pick up on a style,” he told the Associated Press in 1997, “and write in that voice. That’s necessary if you’re going to be successful.”

Margaret Truman, the daughter of President Harry S. Truman, published her first mystery novel set in Washington's corridors of power, "Murder in the White House," in 1980.

Mr. Bain did not help with that book, but he worked as Truman’s ghost writer for the next 23 books in the series.

“Margaret was a joy to work with,” Mr. Bain said in a 2015 interview with the Washington Independent Review of Books, “and I became intimately knowledgeable about her views on Washington and the government.”

He was so knowledgeable that, with the approval of the Truman estate, he continued the “Capital Crimes” series after Truman’s death in 2008, writing five more books, including “Allied in Danger,” which came out this year.

In the Truman books, murders take place at the Supreme Court, at the FBI and CIA, at the Kennedy Center, Washington National Cathedral, Library of Congress and other major institutions around the city.

“My operative philosophy,” Mr. Bain told the Washington Independent Review of Books, “is that when dealing with our nation’s capital and the government, anything that I conjure up, no matter how far-fetched, is possible.”

Donald Sutherland Bain was born March 6, 1935, in Mineola, N.Y. His father worked in manufacturing.

Mr. Bain graduated in 1957 from Purdue University in Indiana, where he studied speech and drama and played drums and vibraphone in jazz groups. He served in the Air Force, spending part of his tour censoring U.S. armed forces television programs in Saudi Arabia.

He worked in radio in Indiana and Texas before settling in New York, where he worked in public relations for an airline.

A cousin who was a ghost writer offered him some magazine assignments, and Mr. Bain launched a new career.

Under his own name, he published “The Case against Private Aviation,” (1969), which called for greater federal oversight of private pilots and commercial airlines, as well as books on bootlegging and the CIA. He co-wrote the autobiography of film star Veronica Lake in 1969.

He revealed many of the tricks of his trade in a 2002 memoir, “Every Midget Has an Uncle Sam Costume,” later published under the title “Murder, He Wrote.”

His first marriage, to Jackie Bain, ended in divorce.

His second wife, writer and occasionally co-author Renee Paley-Bain, died in 2016.

Survivors include two daughters from his first marriage; two stepchildren; four grandchildren; and four step-grandchildren.

Years after the early runaway success of “Coffee, Tea or Me?,” Mr. Bain noted his name appeared only on the book’s dedication page: “I dedicated it ‘To Don Bain, without whom this book wouldn’t have been possible.’ ”