我收到一封电子邮件:
\n\nDear xxx,\n\nThank you. You have just ordered the ultimate treat for your taste buds.\n\nYour yummy, lip smacking delight is being prepared with utmost love and attention at your own neighbouring Pizza Hut \xe2\x80\x93 Bengaluru - Airport Road....\nRun Code Online (Sandbox Code Playgroud)\n\n但是当我说“显示原始内容”时,它显示为:
\n\nMIME-Version: 1.0\nSender: noreply@pizzahut.co.in\nFrom: noreply@pizzahut.co.in\nTo: xxx@gmail.com\nReply-To: noreply@pizzahut.co.in\nDate: 19 Sep 2014 19:44:26 +0530\nSubject: PHD: Your order confirmation\nContent-Type: text/html; charset=utf-8\nContent-Transfer-Encoding: base64\nX-AntiAbuse: This header was added to track abuse, please include it with any abuse report\nX-AntiAbuse: Primary Hostname - server.pizzahut.co.in\nX-AntiAbuse: Original Domain …Run Code Online (Sandbox Code Playgroud) 我正在使用 gmail API 来搜索消息。我想包含一些搜索参数,但我不知道如何使用多个搜索参数。我想做 old_than 和 -unsubscribe
$(document).ready(function() {
var submitButton = 0;
function randomPicture (){
min = Math.ceil(1);
max = Math.floor(14);
var pictureNumber = Math.floor(Math.random() * (max - min)) + min;
$('.sidetext').css('background-image', 'url(images/pic'+pictureNumber+'.jpg)');
console.log(pictureNumber);
}
$('#submit').click(function(){
randomPicture();
var searchTerm = $('#input-person').val();
listMessages('me', searchTerm, listMessageCallback);
submitButton = submitButton + 1;
$('.quote').remove();
});
function listMessages(userId, query, callback) {
$('#content').css('left', $('sidetext'.offsetLeft));
var getPageOfMessages = function(request, result) {
request.execute(function(resp) {
result = result.concat(resp.messages)
};
var initialRequest = gapi.client.gmail.users.messages.list({
'userId': userId,
'q': query
}); …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照 Google 的 Node API 在此处访问 gmail 。
将他们的示例快速入门作为 运行node quickstart.js时,出现以下错误:
TypeError: Cannot read property 'client_secret' of undefined
at authorize (/home/user/example/quickstart.js:32:43)
at processClientSecrets (/home/example/bstick/quickstart.js:21:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)
Run Code Online (Sandbox Code Playgroud)
client_secret.json,并将其复制到quickstart.jsnode --version= 7.8.0, package.json 有"google-auth-library": "^0.10.0",
"googleapis": "^19.0.0"源代码(谷歌的例子):
var fs = require('fs');
var readline = require('readline');
var google = require('googleapis');
var googleAuth = require('google-auth-library');
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/gmail-nodejs-quickstart.json
var SCOPES …Run Code Online (Sandbox Code Playgroud) 我在使用 client_secret.json 文件的 .Net 项目中使用 Gmail API。
那是完全免费的,还是我们需要为使用 Gmail API 支付任何费用?
还有 client_secret.json 的有效期是多久?文件有没有过期?
我正在尝试为我的 G Suite 邮箱制作一个自动归档脚本。
该脚本包含一个搜索查询,然后应该获取所有找到的结果,从收件箱中删除并向其添加自定义标签(存档)。
我正在努力解决这个问题addLabel。它抛出一个错误,InternalError: Cannot find method addLabel(string).但是当我检查文档时,它似乎是正确对象上的正确方法。
任何帮助,将不胜感激。
自动 Gmail 归档
var ARCHIVE_LABEL = "archived";
var AUTO_ARCHIVE_AFTER = "30";
function Intialize() {
return;
}
function Install() {
ScriptApp.newTrigger("autoArchive")
.timeBased()
.at(new Date((new Date()).getTime() + 1000*60*2))
.create();
ScriptApp.newTrigger("autoArchive")
.timeBased().everyDays(1).create();
}
function Uninstall() {
var triggers = ScriptApp.getScriptTriggers();
for (var i=0; i<triggers.length; i++) {
ScriptApp.deleteTrigger(triggers[i]);
}
}
function autoArchive() {
var age = new Date();
age.setDate(age.getDate() - AUTO_ARCHIVE_AFTER);
var auto = Utilities.formatDate(age, Session.getScriptTimeZone(), "yyyy-MM-dd"); …Run Code Online (Sandbox Code Playgroud) gmail google-apps google-apps-script gmail-api google-workspace
正如许多其他人所写,我也遇到了这个问题,我在尝试通过 API 设置新的电子邮件签名时遇到了这个问题
确切的 API 调用是:
sendAsConfiguration = {
'signature': 'Test email signature'
}
result = gmailService.users().settings().sendAs().patch(userId='xxx@domain.com',
sendAsEmail="xxx@domain.com",
body=sendAsConfiguration).execute()
Run Code Online (Sandbox Code Playgroud)
确切的回应是:
google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', '{\n "error": "unauthorized_client",\n "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."\n}')
Run Code Online (Sandbox Code Playgroud)
我的场景如下:
我正在寻找编写一个 PHP 脚本来扫描我的 gmail 收件箱,并阅读未读的电子邮件。不需要用户交互。这必须发生在执行 PHP 文件的 cronjob 上。
这甚至可以通过 API 实现吗?Google 的文档绝对糟糕透了,似乎没有任何示例可以让您以编程方式授权登录。他们总是要求用户在 oauth 请求上物理按下允许按钮。
有没有人尝试过简单地登录并列出您的消息而无需人工交互的经验?
我只是在玩基于本教程https://cloud.google.com/blog/products/gcp/deepbreath-preventing-angry-emails-with-machine-learning的 chrome 扩展。
当我出于某种原因使用扩展程序时,我无法使用 gmail.js https://github.com/josteink/gmailjs-node-boilerplate获取草稿电子邮件的正文。
使用 gmail.js 样板,
"use strict";
console.log("Extension loading...");
const jQuery = require("jquery");
const $ = jQuery;
const GmailFactory = require("gmail-js");
const gmail = new GmailFactory.Gmail($);
window.gmail = gmail;
/*
This code uses the Gmail library to observe emails being sent, turn them into XML,
then return a json data, body, which is put into the request and parsed with ML.
*/
gmail.observe.on("load", () => {
const userEmail = gmail.get.user_email();
console.log("Hello, " + …Run Code Online (Sandbox Code Playgroud) 只是好奇电子邮件标头是否由 Gmail 标记以表示电子邮件是已安排还是立即发送。
gmail-api ×10
gmail ×4
email ×3
javascript ×3
.net ×1
c# ×1
gmail.js ×1
google-api ×1
google-apps ×1
google-oauth ×1
node.js ×1
php ×1