gpt4 book ai didi

Get Emails from Gmail Inbox which does not have specific label attached to it using Google Apps Script(使用Google Apps脚本从未附加特定标签的Gmail收件箱获取电子邮件)

转载 作者:bug小助手 更新时间:2023-10-24 21:02:41 28 4
gpt4 key购买 nike



In my Gmail inbox, emails are coming from a specific email address on a daily basis. I have a script that gets data from them and then attaches a specific label to them. As the emails are increasing day by day, the run time of the script is also increasing. I am looking for a solution that checks the following conditions before processing the email/conversation:

在我的Gmail收件箱中,每天都有来自特定电子邮件地址的电子邮件。我有一个脚本,可以从它们那里获取数据,然后将特定的标签附加到它们上。随着电子邮件的日益增多,脚本的运行时间也在增加。我正在寻找一种解决方案,在处理电子邮件/对话之前检查以下条件:


1. It is coming from a specific email address?

1.它来自特定的电子邮件地址吗?


2. There should not be any label attached to it

2.不得贴上任何标签


Here is the sample script right now:

下面是现在的示例脚本:


function checkEmailsFromSpecificAddress() {

var emailAddress = "[email protected]"; // Replace with the desired email address
var processedMail= GmailApp.getUserLabelByName("Label Attached");
var threads = GmailApp.search('from:' + emailAddress);

if(threads.length>0){

for (var i = 0; i < threads.length; i++) {

var messages = threads[i].getMessages();
threads[i].addLabel(processedMail).refresh();

for (var j = 0; j < messages.length; j++) {

//Get the required data

}
}
}
}

I want the script to consider only those emails where the label is not attached. I have one more question:

我希望脚本只考虑那些标签没有附上的电子邮件。我还有一个问题:


3. The above script adds a label to a thread, if we devise a method that would overlook the thread where the label is attached, does that mean that every new email coming into that thread would not be processed as well? If yes, then how to avoid it?

3.上面的脚本向一个线程添加了一个标签,如果我们设计了一个方法来忽略附加标签的线程,这是否意味着进入该线程的每一封新电子邮件都不会被处理?如果是,那么如何避免呢?


Any help would be greatly appreciated.

任何帮助都将不胜感激。


更多回答

Labels are not attached to messages. They’re attached to threads.

标签不会附加到邮件。它们是用线连接的。

Although I'm not sure whether I could correctly understand your 3 questions, I proposed an answer. Please confirm it. If I misunderstood your questions and my answer was not useful, I apologize.

虽然我不确定我是否能正确理解你的三个问题,但我提出了一个答案。请确认一下。如果我误解了你的问题,我的回答没有用,我道歉。

@EagleEye Thank you for replying. From your reply, I understood that my understanding of your question was not correct. In this case, I have to delete my answer. I deeply apologize for my very poor English skill.

@谢谢你的回复。从你的回答中,我明白了我对你的问题的理解是不正确的。在这种情况下,我必须删除我的答案。我为我糟糕的英语表达深深的歉意。

@EagleEye And, unfortunately, I cannot understand My question was, If the new email comes into a thread where the label is already attached, that means the script will ignore the thread and will not process the new email, hope I was clear enough.. By this, I cannot think of a solution to your actual question. I deeply apologize for my very poor English skill again. But, I would like to support you. When I could correctly understand your actual question, I would like to think of a solution.

@EagleEye,不幸的是,我不能理解我的问题是,如果新电子邮件进入标签已经附加的线程,这意味着脚本将忽略该线程,不会处理新电子邮件,希望我已经足够清楚。这样的话,我想不出解决你实际问题的办法。我再次为我糟糕的英语水平深表歉意。但是,我愿意支持你。当我能正确理解你的实际问题时,我会想出一个解决方案。

thank you for assistance, please ignore 3rd question, we can narrow it down, Can we develop a script that would check if there is no label attached to the thread?

谢谢你的帮助,请忽略第三个问题,我们可以缩小范围,我们可以开发一个脚本,将检查是否有标签附加到线程?

优秀答案推荐
更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com