Skip to content

Instantly share code, notes, and snippets.

@kerinin
Created March 27, 2013 21:21
Show Gist options
  • Save kerinin/5258116 to your computer and use it in GitHub Desktop.
Save kerinin/5258116 to your computer and use it in GitHub Desktop.
def get_message_infos_after_date(ymail_folder, last_date)
messages = []
oldest_found = Time.now.to_i
last_date = last_date.to_i
offset = 0
while oldest_found > last_date
hash = self.request('ListMessages', :fid => ymail_folder.fid, :sortKey => "date", :sortOrder => "down",
:startInfo => offset, :startMid => offset, :numInfo => 100, :numMid => 100)
found_messages = hash['result']['messageInfo'].map{|h| Ymail::YmailApi::DataTypes::MessageInfo.make_from_hash(h,ymail_folder)}
messages.push(*found_messages)
if found_messages.size < 100
break
else
offset += 100
oldest_found = messages.last.received_date
end
end
messages.select { |m| m.received_date > last_date }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment