how to use GMAIL API query filter for datetime

此生再无相见时 提交于 2020-01-10 02:03:14

问题


I am using GMAIL API over REST interface to read mails from gmail server, my problem is when I am using date filter by giving a date as 'after:2014/8/20 before:2014/8/22' then the mails starting from 2014/8/20 12.30 PM onwards are downloaded (ideally it should consider mails from 12.00 AM). Mails from night 12.00 AM till noon 12.30 PM are skipped. I think server is using PST time zone. Can I specify time in the filter? or is there a way to specify time zone so that I get all the mails.

code used:

    UsersResource.MessagesResource.ListRequest      request         = null;
    ListMessagesResponse                            response        = null;
    request                 =   gmailServiceObj.Users.Messages.List(userEmail);
    String query            =   "after:" + FromDate.Date.ToString("yyyy/M/dd") + "   before:" + ToDate.Date.ToString("yyyy/M/dd") + " label:" + LabelID;  
    request.Q               =   query;             

Thanks, Haseena


回答1:


It does appear that the timezone being used when processing these queries is always PST. There is currently no way to specify the timezone in the request, or have it use the timezone of the account. I'll follow up with the engineering team to come up with a resolution.




回答2:


The behavior of the API in this regard should be the same as the web UI, can you verify if that's not the case? The search query params are listed here: https://support.google.com/mail/answer/7190?hl=en

It seems odd that it wouldn't deliver emails between 12:00AM and 12:30AM, what timezone is your client in? What's the timezone preference set to in the Gmail web interface for the user? You could try changing that preference and see if it helps? If not, one workaround I can think of is to have the filter from the day before and do the filtering client-side, as ugly as that is... :-/



来源:https://stackoverflow.com/questions/25427670/how-to-use-gmail-api-query-filter-for-datetime

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!