Is there a way to get the oldest UNREAD mail from a GMAIL mailbox using the REST API - gmail-api

Is there a way using gmail rest API to get the oldest UNREAD mail or list eg. 10 oldest UNREAD mails?
Right now i am getting all unread mails from a specific email folder by looping using nextPage until i reach the last page. There i get the last message id, which seems to refer to the oldest email. I works and the mail id's seems to be listed in order newest first and oldest last in the list.
This is the query i am using:
https://gmail.googleapis.com/gmail/v1/users/a.b#gmail.com/messages?labelIds="folderI"&includeSpamTrash=false&pageToken="nextPage"&q=is:unread
Is there a more effective way to get the oldest UNREAD mail or to get a list of say the 10 oldest UNREAD mails?

There is no direct way to do it, but you can use the the q parameter search properties Search operators you can use with Gmail to get the messages from a certain period or with a max date to get less emails to go through.

Related

Is there a workaround for retrieving data for more than 1000 messages using SendGrid Filter All Messages?

I have a requirement of retrieving the activity for certain category of emails sent through our SendGrid account with events occurring before specific time.
For this, I first invoke the filter all messages endpoint of SendGrid to retrieve message IDs of the specific category of messages I am interested in bounding above using last_event_time parameter of the endpoint followed by retrieving activity for individual messages using the Filter message by message ID endpoint with the retrieved message ids.
The problem that I am faced with is that the filter all messages has a limit parameter with maximum value of 1000 while the number of messages for which the last_event_time is equal to a specific timestamp say '2021-10-10T10:10:10Z' can be more than 1000.
In this case, the use of timestamp to iteratively filter messages doesn't work as the response from filter all messages contains data for the same set of 1000 messages. I though of using the message ID's from the data retrieved through filter all messages to exclude data for those in subsequent calls and even tried that out but it errored out because the request uri was too long.
Not sure if I am missing something here.
You can paginate through the responses by adding limit and offset parameters to your request URL.
For example:
https://api.sendgrid.com/v3/resource?limit=1000&offset=1000

QBO SDK PHP getting all deposits customer

I would like to know how to get all deposits of a target customer with the following SDK (https://github.com/intuit/QuickBooks-V3-PHP-SDK).
Is there an easier way than getting all deposits, then looping to extract the wanted customer's deposits?
Official QBO answer:
You can get complete deposit list by querying the “Query a deposit”
API end point. If we use filter in query, then it may return incorrect
results. Better you can iterate the response and add filter logic in
your code and get specified

Is it possible to get recent 5 emails using the gmail -API from one specific sender

Through another question I was able to limit the number of results but I was wondering if there is a way to filter the messages and only pull them from one sender?
Thank you
You can use the query parameter (q) which supports advanced search syntax. For example, if the sender you want messages from is: mysender#mydomain.com, you can use:
https://www.googleapis.com/gmail/v1/users/me/messages?maxresults=5&q=from:mysender#mydomain.com
Take into account that this will only send back the id and threadId of the emails. If you want more info about the messages you should use messages.get for each message.

SilverPOP API - Automated message report

I need to export all data from Silverpop automated message with silverpop API
apparently there are no many information on the net apart from the official guide "XML API Developer’s Guide ENGAGE"
I need to know how to:
retrieve a list of Automated message
extract / download data of selected report (for all days-not single one)
finally (again not documented in the official guide); how to programmatically export final report having set MOVE_TO_FTP=true
(the guide quotes Use the MOVE_TO_FTP parameter to retrieve the output file programmatically)
thank you very much in advance for any help in this
You can use the RawRecipientDataExport XML API export to get the following:
• One or more mailings
• One or more Mailing/Report ID combinations (for Autoresponders)
• A specific Database (optional: include related queries)
• A specific Group of Automated Messages
• An Event Date Range
• A Mailing Date Range
For automated messages, you can use the following XML tags <CAMPAIGN_ACTIVE/>, <CAMPAIGN_COMPLETED/>, and <CAMPAIGN_CANCELLED/> to retrieve active Groups of Automated Messages, retrieve completed Groups of Automated Messages, and retrieve canceled Groups of Automated Messages, respectively.
To get data for all days and not just one, you can set a date range for send dates and event dates, by putting your desired date ranges within the <SEND_DATE_START> and <SEND_DATE_END> tags and <EVENT_DATE_START> and <EVENT_DATE_END> tags. The date formats are like this: 12/02/2011 23:59:00
Hope this helps.

How to restrict the answer size in javamail search method?

I am using Javamail library to fetch emails from several servers through IMAP.
I only care for the unread messages and I want to download only the 5 last received unread messages.
For filtering the messages in a folder I am using using the Folder.search(FlagTerm ft) method passing the flag SEEN with value false, just as following code shows:
FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
Message[] messages = folder.search(ft);
I need to diminish bandwidth usage and the above method may return an arbitrarily large number of messages. I am only interested in the last 5 of them, is there a way for the IMAP server return a limited number of messages?
You can do the search over a subset of the messages, effectively setting an upper limit on the number of messages returned, but you might have to do multiple searches. There's no direct way to limit the number of results returned if you're searching all messages.
Note that the search results are relatively compact (effectively only the message number), so unless you're searching a huge number of messages I wouldn't think bandwidth would be an issue relative to fetching the content of the messages.

Resources