【问题标题】:GMail API SendAs GET not showing displayname without aliasGMail API SendAs GET 不显示没有别名的显示名称
【发布时间】:2021-05-26 10:55:45
【问题描述】:

似乎无法找到直接解决此问题的问题,但有谁知道为什么端点 https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/list 在未设置别名时没有列出默认显示名称?

{
  "sendAs": [
    {
      "sendAsEmail": "foo@gmail.com",
      "displayName": "",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    }
  ]
}

根据我的测试,如果您使用此处列出的步骤 https://support.google.com/mail/answer/8158?hl=en 创建备用显示名称,响应将显示为

{
  "sendAs": [
    {
      "sendAsEmail": "foo@gmail.com",
      "displayName": "New Alternate Name",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    }
  ]
}

如果您将另一个电子邮件地址添加到别名,您会得到

{
  "sendAs": [
    {
      "sendAsEmail": "foo@gmail.com",
      "displayName": "New Alternate Name",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    },
    {
      "sendAsEmail": "foo2@gmail.com",
      "displayName": "Foo 2 Name",
      "replyToAddress": "",
      "signature": "",
      "treatAsAlias": true,
      "verificationStatus": "accepted",
      "isDefault": false
    }
  ]
}

但是,如果您将主电子邮件的显示名称恢复为原始默认值,您会得到

{
  "sendAs": [
    {
      "sendAsEmail": "foo@gmail.com",
      "displayName": "",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    },
    {
      "sendAsEmail": "foo2@gmail.com",
      "displayName": "Foo 2 Name",
      "replyToAddress": "",
      "signature": "",
      "treatAsAlias": true,
      "verificationStatus": "accepted",
      "isDefault": false
    }
  ]
}

在本地使用 Java 时遇到问题,但在“尝试此 API”功能上对其进行测试会产生相同的结果,所以我认为这是 WAD,我可能需要使用其他东西。

【问题讨论】:

    标签: google-api gmail gmail-api google-apis-explorer


    【解决方案1】:

    资源user.settings.sendAs的方法list返回一个SendAs对象,该对象包含一个名为displayName的字段,其描述为:

    使用此别名发送的邮件的“发件人:”标头中显示的名称。

    这意味着如果您不使用别名,它将为空。如果您想检索您帐户的全名,您可以使用 Admin API,使用资源 users 的方法 get,但它仅限于您域的管理员用户。

    参考:

    【讨论】:

      猜你喜欢
      • 2017-01-23
      • 1970-01-01
      • 2015-01-01
      • 2019-03-16
      • 1970-01-01
      • 2021-05-04
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      相关资源
      最近更新 更多