title: Retrieve array of gmail message bodies by sender/date with Gmail API in Ruby
body: <p>junior developer here with a gmail api question. My rails app needs to search for and retrieve around 300 gmail messages whose bodies it will then scrape using nokogiri. I've installed the google-api-client gem, and successfully configured authorization following this person's <a href="http://readysteadycode.com/howto-access-the-gmail-api-with-ruby" rel="nofollow noreferrer">guide</a>. Using their example I can successfully retrieve a user's list of labels with the following code:</p>
  
  <pre><code>client = Signet::OAuth2::Client.new(access_token: session[:access_token])
  client.expires_in = Time.now + 1_000_000
  service = Google::Apis::GmailV1::GmailService.new
  service.authorization = client
  @labels_list = service.list_user_labels('me')
  </code></pre>
  
  <p>I tried searching google's ruby api docs for how to do the search I want, but their docs are pretty sparse. It seems that I'll need to run at least two separate queries - the first to retrieve a list of messages that meet the sender and date parameters of my search, and then an additional query to retrieve the message body. The syntax for this is eluding me though. I've played around with the gmail ruby api instance methods for <code>#list_user_messages</code> and <code>#get_user_message</code> and have had no luck getting them to work. Anyone here with experience using them?</p>