The answer is relatively simple, in that Gmail ads are pulled from Google's content network. Google does matching on the text of the email, much like how they match the text of the content of a page on the AdSense network.
The Gmail help page says "ads in Gmail are placed in the same way that ads are placed alongside Google search results and, through the Google AdSense program, on content pages across the web."
So if you opt your ads into Google's content network, your ads may appear in Gmail, as per.
Forum discussion at DigitalPoint Forums.