Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 使用谷歌应用程序脚本读取电子邮件标题_Google Apps Script - Fatal编程技术网

Google apps script 使用谷歌应用程序脚本读取电子邮件标题

Google apps script 使用谷歌应用程序脚本读取电子邮件标题,google-apps-script,Google Apps Script,我想通过阅读我所有的Gmail邮件的标题来找到具体的信息 我知道没有通过GmailApp服务的访问权限(好吧,无论如何,我很确定) 有关如何使用主要基于应用程序脚本的解决方案获取标题信息的任何想法?不,电子邮件标题无法通过应用程序脚本服务获得。为此,您必须使用SMTP或SMTP路由 -- 更新 你让我好奇,看起来你可以通过getRawContent()手动解析重要的内容 以下是您可以尝试的代码- function processInbox() { //get first message in

我想通过阅读我所有的Gmail邮件的标题来找到具体的信息

我知道没有通过GmailApp服务的访问权限(好吧,无论如何,我很确定)


有关如何使用主要基于应用程序脚本的解决方案获取标题信息的任何想法?

不,电子邮件标题无法通过应用程序脚本服务获得。为此,您必须使用SMTP或SMTP路由

-- 更新

你让我好奇,看起来你可以通过
getRawContent()
手动解析重要的内容

以下是您可以尝试的代码-

function processInbox() {
  //get first message in first thread
  var message = GmailApp.getInboxThreads(0,1)[0].getMessages()[0];
  Logger.log(message.getRawContent());
};
这是LinkedIn组消息的输出-

From: Google APPS users Group Members <group-digests@linkedin.com>
To: Arun Nagarajan <REMOVED@gmail.com>
Message-ID: <1440795364.35263280.1354293878345.JavaMail.app@ela4-app2521.prod>
Subject: [2] discussions, [1] comment and [1] job on LinkedIn
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_35263277_1178500841.1354293878345"
X-LinkedIn-Template: anet_digest_type
X-LinkedIn-Class: GROUPDIGEST
X-LinkedIn-fbl: s-uPmFAdhOYxvH52TwUlkvTF6rOfu4R6CRfjIFaaCOYfXQgGt9OunBRp

------=_Part_35263277_1178500841.1354293878345
Content-Type: multipart/related; 
    boundary="----=_Part_35263278_821958406.1354293878345"

------=_Part_35263278_821958406.1354293878345
Content-Type: multipart/alternative; 
    boundary="----=_Part_35263270_1718315066.1354293878331"

------=_Part_35263270_1718315066.1354293878331
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

message here
<snip>
发件人:谷歌应用程序用户组成员
收件人:Arun Nagarajan
消息ID:
主题:[2]讨论,[1]评论和[1]在LinkedIn上的工作
MIME版本:1.0
内容类型:多部分/混合;
boundary=“---=_Part_35263277_117850841.1354293878345”
X-LinkedIn-Template:anet_digest_类型
X-LinkedIn-Class:GROUPDIGEST
X-LinkedIn-fbl:s-uPmFAdhOYxvH52TwUlkvTF6rOfu4R6CRfjIFaaCOYfXQgGt9OunBRp
------=_零件_35263277_117850841.1354293878345
内容类型:多部分/相关;
boundary=“---=”U部件--U 35263278--U 821958406.1354293878345”
------=零件号\u 35263278 \u 821958406.1354293878345
内容类型:多部分/备选;
boundary=“--------=_Part_35263270_1718315066.1354293878331”
------=_零件_35263270_1718315066.1354293878331
内容类型:文本/纯文本;字符集=UTF-8
内容传输编码:7bit
留言

谢谢@Arun,在你的上面加上一个小例子, 例如,要获取“X-LinkedIn-Template”标题值:

var header = message.getRawContent().match(/(X-LinkedIn-Template:)(.*)/);
header[0] // the whole match == X-LinkedIn-Template: anet_digest_type
header[1] // the header key  == X-LinkedIn-Template
header[2] // the value       == anet_digest_type
也有可用的方法。