【问题标题】:How to change email status google api c#如何更改电子邮件状态google api c#
【发布时间】:2019-01-27 06:22:08
【问题描述】:

我正在使用 Google API C# 代码在我的 Gmail 中按照代码将未读电子邮件标记为已读。这是代码

但我收到以下错误:

Google.Apis.Requests.RequestError Insufficient Permission [403] 错误 [Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]]

如何使用 Google API C# 解决 Gmail 阅读的这个问题

【问题讨论】:

  • "insufficientPermissions" - 您需要查看文档以了解执行该操作所需的权限,
  • 我已经阅读了一些文档。但是我没有找到解决这个问题的正确方法
  • 你能告诉我们你的代码吗?

标签: asp.net google-api gmail-api google-api-dotnet-client


【解决方案1】:

Messages.modify 方法允许您对消息进行更改。您需要修改消息并删除 UNREAD 标签。然后该消息将显示为已读

public static Message ModifyMessage(GmailService service, String userId,
      String messageId, List<String> labelsToAdd, List<String> labelsToRemove)
  {
      ModifyMessageRequest mods = new ModifyMessageRequest();
      mods.RemoveLabelIds = "UNREAD";

      try
      {
          return service.Users.Messages.Modify(mods, userId, messageId).Execute();
      }
      catch (Exception e)
      {
          Console.WriteLine("An error occurred: " + e.Message);
      }

      return null;
  }

无法访问

此方法需要以下访问范围之一

【讨论】:

  • Google.Apis.Requests.RequestError Insufficient Permission [403] 错误 [Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]]
猜你喜欢
  • 2019-01-26
  • 1970-01-01
  • 2017-05-18
  • 1970-01-01
  • 1970-01-01
  • 2019-01-12
  • 1970-01-01
  • 1970-01-01
  • 2018-10-19
相关资源
最近更新 更多