The letter, which spells out the bond between the two leaders who come from different political ideologies, was shared by the former president on Twitter today.
"On my last day in office as the President, I received a letter from PM @narendramodi that touched my heart! Sharing with you all," Mukherjee said in a tweet.
Modi said he had come to New Delhi, three years ago, as an outsider.
The prime minister said Mukherjee's "intellectual prowess" had been of constant help.
More From This Section
"You have been so warm, affectionate and caring to me. Your one phone call asking me 'I hope you are taking care of your health' was enough to fill me with fresh energy, after a long day at meetings or on a campaign tour," he said in the letter dated July 24.
"Pranab Da, our political journeys took shape in different political parties. Our ideologies, at times, have been different. Our experiences are also varied. My administrative experience was from my state, whereas you have seen the expanse of our national polity and politics for decades.
"Yet, such is the strength of your intellect and wisdom that we were able to work together with synergy," Modi said.
The BJP leader praised the Congress veteran and former president for opening the Rashtrapati Bhavan to initiatives and programmes that recognised innovation and the talent of India's youth.
The prime minister said he and all others would continue to draw strength from Mukherjee's democratic vision of "taking everybody along".
"Rashtrapati Ji, it has been an honour to work with you, as your Prime Minister," Modi said.