Apple CEO Tim Cook has found the "recipe" for a positive relationship with President Donald Trump, management expert Jeffrey Sonnenfeld told CNBC on Thursday.

"Trump runs hot and cold on people," the senior associate dean at the Yale School of Management said on "Closing Bell." "I don't think many people would have predicted [the relationship between Tim Cook and Donald Trump]."

The president praised the Apple CEO after the two had dinner in Bedminster, New Jersey, at Trump's golf club last week. "That's why he's a great executive. ... Because he calls me and others don't," Trump told reporters Wednesday.

When talking about business leaders building relationships with the president, Sonnenfeld, who is also a CNBC contributor, said, "There are a lot of risks, a lot of reputation risks. There's volatility but there were [also] very high hopes. This is our first CEO president in American history."

The management expert explained that during the last election, "most of the major business communities did not support him. Almost 80% [of the Republican business executives] didn't support him for president."

He added, "It's fitful. Even though he wants to use relationships, much of the public doesn't appreciate him. He's not one of them. He positions himself as one of them but they never saw him as one. His enterprise was never near the scale of any of these people's businesses. He felt rejected from their club. So there's some resentment there."

Although Cook has publicly criticized Trump for his environmental and immigration polices and the president's remarks on the white nationalist rally in Charlottesville, Virginia, he has found and "given [the business community] a recipe" for how to manage a positive relationship with the president, according to Sonnenfeld.

The CEO reportedly made a "good case" to Trump during the dinner meeting that it would be hard for Apple to pay tariffs while competing against its South Korean rival Samsung. Cook argued that the additional duties would be unfair in comparison to Samsung that does most of its manufacturing in South Korea.

Trump suggested that he delayed the 10% tariffs on laptops and cellphones because a majority of Apple's final device assembly takes place in China.