This is a link to more info from Google
http://gmail.google.com/gmail/help/more.html#ads
This is just one paragraph from that page that refers to the scanning of e-mails - there is more:-
"All email services scan your email. They do this routinely to provide such popular features as spam filtering, virus detection, search, spellchecking, forwarding, auto-responding, flagging urgent messages, converting incoming email into cell phone text messages, automatic saving and sorting into folders, converting text URLs to clickable links, and reading messages to the blind. These features are widely accepted, trusted, and used by hundreds of millions of people every day.
Google scans the text of Gmail messages in order to filter spam and detect viruses, just as all major webmail services do. Google also uses this scanning technology to deliver targeted text ads and other related information. This is completely automated and involves no humans.
When a user opens an email message, computers scan the text and then instantaneously display relevant information that is matched to the text of the message. Once the message is closed, ads are no longer displayed. It is important to note that the ads generated by this matching process are dynamically generated each time a message is opened by the userin other words, Google does not attach particular ads to individual messages or to users' accounts.
We recognize that seeing ads based on the content of an email message can be unsettling at first. Our experience has been that this feeling recedes as users become more familiar with Gmail. However, some people, many of whom have not used Gmail, have reacted by condemning all automatic scanning of email content, on the grounds that it amounts to a violation of privacy. We think this criticism is misplaced. All major email services, including Hotmail and Yahoo! Mail, automatically scan email content for the benefit of users. When email messages are fully protected from unwanted disclosure, the automatic scanning of email does not amount to a violation of privacy."
Best to go straight to the horses mouth - unless it really is a gift horse of course in which case you should never look.