When a former Alabama governor started sending suggestive texts to a member of his staff, he probably didn't expect them to sync with the state-issued iPad he had given his wife.

Robert Bentley resigned on Monday after an ethics report concluded he used state resources to conceal an affair with his adviser, Rebekah Caldwell Mason.

But the scandal began in 2013, when his wife, Dianne Bentley, became suspicious of the budding relationship.

In March 2014, according to the report, Dianne placed a recorder inside her purse and discovered that her husband had called Mason and declared his love for her — a minute after Dianne left the room.

Robert's efforts to dispose of the recordings led to many of the accusations that he misused funds. He later pleaded guilty to them.

On the night of his reelection in the 2014 gubernatorial race, Robert was convinced that his opponent had a copy of the recording and told Alabama Law Enforcement Secretary Spencer Collier to travel to Greenville to retrieve it, according to the report.

Dianne's chief of staff, Heather Hannah, claimed Robert told her she would "never work in the state of Alabama again" if she told anyone about the affair, the report says.

After finding Robert's inappropriate text messages, Dianne filed for divorce from her husband of 50 years in 2015.

Some of the text messages Robert sent Mason included:

"You look beautiful and feel so soft."

"Bless our hearts. And other parts."

"I love you, Rebekah 😍😍 "

Texts between Rebekah Mason and Robert Bentley, according to the ethics report. Bentley Investigation

After Robert discovered that Dianne was reading his text messages, he started using burner phones to communicate with Mason, according to the report.

He fired Collier in 2016, when the administration was investigating his misuse of state funds. The next day, Collier confirmed the existence of the affair to the press.

Rebekah Mason. AP Photo/Brynn Anderson Dianne gave the ethics committee pages of phone logs and text messages to help the investigation.

Robert had denied doing anything illegal or improper up until his resignation.

"I have decided it is time for me to step down as governor," he said at a press conference Monday evening. "The time has come for me to look for new ways to serve the people of our great state."

State lawmakers were deciding whether to impeach the governor when he agreed to plead guilty to two misdemeanor charges, repay the misused funds, and never hold public office again.