我们有一个用例,其中我们拥有草稿的消息 ID,并希望获得不可变的草稿 ID。目前唯一的方法是列出所有草稿并遍历它们,直到找到匹配的消息 ID。
是否可以添加通过消息 ID 查询草稿的功能?或者,如果草稿 ID 可以包含在通过 ID 调用的 Get 消息中,那么这可能会起作用。
我正在关注https://developers.google.com/gmail/api/guides/push 上给出的 Gmail API 推送通知指南。但是,当我尝试从 API 资源管理器创建新手表时,它给出了以下响应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*"
}
],
"code": 400,
"message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*"
}
Run Code Online (Sandbox Code Playgroud)
}
我的要求如下:
POST https://www.googleapis.com/gmail/v1/users/myemailaddress/watch?key={YOUR_API_KEY}
{
"labelIds": [
"INBOX"
],
"topicName": "projects/my-project-name/topics/my-topic-name"
}
Run Code Online (Sandbox Code Playgroud)
似乎在 Google API 端进行了错误的验证检查。还有其他人面临这个问题吗?
我正在使用 javascript 调用 /batch API 方法以一次获取大量消息。根据文档,它返回一个多部分/混合内容类型的 HTTP 响应。我正在尝试将其作为 JSON 循环,但不确定如何转换它。任何帮助将不胜感激。谢谢!
我正在尝试使用Google API 2.0.0 RC4 for PHP从我自己的收件箱(作为项目所有者)获取给定的电子邮件.
我有一个项目设置,一个JSON格式的下载认证文件,我在Google Developers Console中启用了gmail API.
但是,当我运行以下代码时,出现"错误请求"错误,原因是"failedPrecondition".现在这让我相信访问权限存在问题,但我无法弄清楚我需要做什么.
码:
<?php
require_once("google-api-php-client-2.0.0-RC4/vendor/autoload.php");
$client = new Google_Client();
// set the scope(s) that will be used
$client->setScopes(["https://www.googleapis.com/auth/gmail.readonly"]);
$client->setApplicationName("MyProject");
// set the authorization configuration using the 2.0 style
$client->setAuthConfigFile("myAuthFile.json");
$gmailHandle = new Google_Service_Gmail($client);
$messages = $gmailHandle->users_messages->get("myemail@mydomain.com", "12343445asd56");
echo json_encode($messages);
?>
Run Code Online (Sandbox Code Playgroud)
完整的错误看起来像这样:
致命错误:未捕获的异常'Google_Service_Exception',消息'{"错误":{"errors":[{"domain":"global","reason":"failedPrecondition","message":"Bad Request"}], "code":400,"message":"Bad Request"}}'
我正在使用google脚本尝试匹配始终如下所示的字符串部分:* YYYYMMDD; hhmm *例如:* 20170701; 0900 *
我定义了这个正则表达式:
var regExp = ('(?:\*)(?P<date>\d+)(?:\;)(?P<time>\d+)(?:\*)','gi');
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令调用它:
var datepart = textbody.match(regExp);
Run Code Online (Sandbox Code Playgroud)
但是,尽管https://regex101.com/中的相同文本效果很好,但我没有找到任何匹配项。知道我在做什么错吗?
我试图让python程序通过Gmail发送附件。我使用发现的示例代码: 通过gmail和python发送电子邮件
问题是,当我向自己发送.xls,.xlsx,.xlsm之类的Excel文件时,即使原始文件没问题,我也无法打开附件,因为它们已损坏。但是发送.csv可以正常工作。整个过程不会弹出任何警告或错误。
问题是:oauth2.0或Gmail或MIME是否将某些格式的附件弄乱了?以及如何在不修改程序的情况下告诉程序上传和发送附件?
我在c#ASP.net应用程序中使用Gmail API收到收件箱消息。所有邮件均来自不同的时区(州/国家/地区),我想在我自己的时区中显示日期,因为它在Gmail应用程序中显示。我搜索了很多时区之间的转换,但无法解决,可能是因为我没有正确获取它。
我到目前为止但尝试的代码是:(它适用于大多数消息,但对于少数消息却无法正确显示DateTime)
例如:
Gmail应用中显示的时间:30/11/2017 2:11 AM
我的代码来自Gmail API的输入/值:2017年11月29日,星期三10:11:35 -0800
以下是我从当前的Gmail收件箱消息中获取的一些值:
var re = service.Users.Messages.List("me");
re.LabelIds = "INBOX";
re.Q = "is:all";
var res = re.Execute();
if (res != null && res.Messages != null)
{
foreach (var email in res.Messages)
{
var emailInfoResponse = service.Users.Messages.Get("me", email.Id).Execute();
if (emailInfoResponse != null)
{
foreach (var mParts in emailInfoResponse.Payload.Headers)
{
if (mParts.Name == "Date")
{
date = mParts.Value;
}
}
}
}
}
My Time Zone is: (UTC+08:00) Perth
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。谢谢!
我正在尝试使用Google的发布/订阅为Gmail订阅邮件通知,并且已经阅读了Google提供的文档和教程。有一次,文档指出我需要发布对PubSub主题的正确权限:
您需要向授予
publish特权serviceAccount:gmail-api-push@system.gserviceaccount.com。您可以按照资源级访问控制说明使用Cloud Pub / Sub Developer Console权限界面执行此操作。
我的理解是,该publish特权等同于pubsub.topics.publish“ PubSub Publisher”或只是“ PubSub Publisher”。但是serviceAccount:gmail-api-push@system.gserviceaccount.com呢?我在任何地方都找不到该服务帐户,并且由于字符限制,控制台不允许我创建该服务帐户。还有另一种获取此帐户的方法吗?
gmail-api ×10
google-api ×2
javascript ×2
php ×2
asp.net ×1
c# ×1
excel ×1
gmail ×1
google-oauth ×1
mime ×1
oauth ×1
oauth-2.0 ×1
python ×1
regex ×1