The British comedian confessed the pair first bonded after they penned a song together – entitled 'Pug-Nosed Face' – and then began sending emails back and forth.
He explained: "I’ve written a song with him – it was called ‘Pug-Nosed Face’ and it was about me! I sent him the lyrics and I was talking to him on the phone and I was going, ‘If you could do something really retro like 'Life on Mars'?’ and he went, ‘Oh sure, I’ll just knock off a 'Life on Mars' for you then shall I?’ It was great!
"Later he must have got my email and he said, ‘I watched 'The Office'. It was funny. I laughed. What do I do now?’ and we sort of became pen pals."
Ricky also admitted he has even been sending the legendary star abusive emails.
He added to Magic 105.4 radio station: "I remember I sent him an email on his 57th birthday and I said, ‘57! Isn’t it about time you got a proper job? Ricky Gervais, 42, comedian.’ And he wrote back, ‘I have a proper job. David Bowie, 57, rock god'."
The full interview takes place on November 28 on British station Magic 105.4.