Using IMAP with the Gmail Data Provider



The CData ADO.NET Provider for Gmail enables you to search Gmail with standard SQL. The provider supports the full capabilities of the IMAP search command. This article will show how to execute some typical searches on a mailbox. You will use the CData Gmail Data Provider along with the demo application to execute queries on a Gmail account.

  1. Navigate to the \demos - winform\googlemail\ folder in your installation directory and open either the C# or VB version of the demo. This article will use the C# version.
  2. Build and run the demo. Enter your credentials and click the Connect button.
  3. After connecting, select a mailbox to retrieve the individual messages contained.
  4. The Advanced Search Options panel contains fields that allow you to search based on a number of different simple search criteria. You can search using as many of these criteria at one time as you like.
  5. When you click Search, the demo application adds the criteria you defined to the query. This is added in the WHERE clause. For example, if you search for all emails from Twitter in your Inbox since a certain date, the query executed will be the following:

    SELECT * FROM MailMessages 
    WHERE (FROM='Twitter' AND Date > '11-25-2012') 
          AND Mailbox=Inbox

You can use the following columns in the WHERE clause: To, From, BCC, CC, Subject, MessageBody, Flags, Labels, Size, and Date. For a look at more advanced queries see: Using SQL to query Gmail.

 
 
Downloads