Gmail API停止检索特定日期的正确电子邮件

时间:2017-02-16 03:02:51

标签: c# gmail-api

我已编写代码来检索标签,然后根据所选标签 - 返回Gmail API中的电子邮件列表。但我注意到的是,它对于一些请求完全正常,然后在某些时候我的应用程序崩溃了Http Host某些东西或更确切的错误(它被截断),我重新启动了我的应用程序 - 它从那时起就没有像预期的那样工

代码片段:

检索所有标签:

public Dictionary<string, string> GetAllLabels(string userId) {
    Dictionary<string, string> labels = new Dictionary<string, string>();

    try {
        ListLabelsResponse response = _service.Users.Labels.List(userId).Execute();
        foreach (var label in response.Labels) {
            labels.Add(label.Id, label.Name);
        }
    } catch (Exception e) {
        Console.WriteLine("An error occurred: " + e.Message);
    }

    return labels;

检索邮件的部分代码:

    var result = new List<Google.Apis.Gmail.v1.Data.Message>();
    UsersResource.MessagesResource.ListRequest request = _service.Users.Messages.List(userId);
    request.LabelIds = labelId;
    request.Q = query;

    do {
        try {
            ListMessagesResponse response = request.Execute();

我可以看到labelIdquery设置为正确的值:Label_5after:2017/2/16 before:2017/2/17

因为如果我查找Label_5是什么 - 它会返回正确的标签,如果我将日期过滤器复制粘贴到搜索栏中 - 它会返回正确的电子邮件,排在第16位。

但不是像以前一样检索第16个数据 - 现在突然之间,如果我通过应用程序传递after:2017/2/15 before:2017/2/16并且请求的电子邮件,那么16日收到的电子邮件现在才会被返回16日:after:2017/2/16 before:2017/2/17现在返回null(同样,这只发生在Gmail用户界面中 NOT 中)。这对我来说毫无意义,为什么突然间它会改变这样的行为。

似乎它与API本身而不是我的代码有关,这个问题有解决方法吗?任何帮助将不胜感激。

0 个答案:

没有答案
相关问题