Gmail,第一个带有标签的电子邮件进入Google表格 [英] Gmail, First email in thread with labels logging into google sheet

查看:53
本文介绍了Gmail,第一个带有标签的电子邮件进入Google表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

预先感谢您的帮助.

我是Google脚本的新手&如果有人可以帮我编写脚本.这将帮助我完成任务和学习过程.

I am new to google scripting & if someone can help me with a script. It will help me in a task as well as in the learning process.

我有一个任务来记录所有带有特定标签的工作表中的电子邮件,比如说"XYZ"

I have a task to record all the emails in google sheets with a specific label, let's say "XYZ"

我需要在Google工作表中

In the google sheet, I need

  1. 该线程的第一封电子邮件的发件人
  2. 该主题的第一封电子邮件的日期
  3. 该主题的第一封电子邮件中的所有标签
  4. 该主题的第一封电子邮件的主题

谢谢:)

推荐答案

这应该可以帮助您入门.它还不完整,但是如果您保持代码格式正确,内容帮助喜欢它的方式并且保持语法错误,那么脚本编辑器中的代码帮助将帮助您完成大部分代码.使用文档,并注意各种功能返回的对象类型.

This should get you started. It's not complete but if you keep you code formatted properly, the way content assist likes it and you keeping fixing syntax errors then code assist in the script editor will help you work your way through most of the code. Use the documentation and pay attention to what kind of object is returned from various functions.

function getEmails() {
  var threads=GmailApp.getInboxThreads();
  for(var i=0;i<threads.length;i++) {
    var thread=threads[i];
    var firstmessage=thread.getMessages()[0];
    var firstmessagesender=firstmessage.getFrom();
    var firstMessageSubject=thread.getFirstMessageSubject();
    var firstMessageLabels=thread.getLabels();

  }
}

这篇关于Gmail,第一个带有标签的电子邮件进入Google表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆