如何在没有Gmail API原始邮件的情况下获取回复邮件 [英] How to get the reply message without the original message from the Gmail API

查看:140
本文介绍了如何在没有Gmail API原始邮件的情况下获取回复邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在没有原始消息的线程中获得回复消息。但是,当我使用Users.messages:GET或Users.threads:GET时,我也会收到原始消息(不需要)的回复(根据需要)。请参阅下面的截图代码。

I would like to get the reply message in a thread without the original message. However, when I use either Users.messages: GET or Users.threads: GET, I receive the reply (as desired) with the original message (undesired) as well. See screenshot below code.

(据我所知,这个问题也提出了这里,但是我没有发现提出的解决方案能够回答这个问题并提出解决方案的海报建议我开始一个新的问题,我尝试与Users.threads作为Tholle建议,但收到了相同的结果。)

(This question, as far as I can tell, was also posed here, however I did not find that the proposed solution answers the question and the poster of the proposed solution suggested I start a new question. I tried with Users.threads as Tholle suggests however received the same result.)

我是一个noob ,所以任何和所有的帮助非常感谢,我很抱歉,如果我失去了明显的东西。

I'm a noob, so any and all help is greatly appreciated and I apologize if I'm missing something obvious.

var gapiGETRequest = function (gapiRequestURL)
  {
      var xmlHttp = new XMLHttpRequest();
      xmlHttp.open( "GET", gapiRequestURL, false );
      xmlHttp.send( null );
      return xmlHttp.responseText;
  }

var gapiRequestInboxMessagesAndToken = "https://www.googleapis.com/gmail/v1/users/me/messages?q=-label%3ASENT+in%3AINBOX&access_token=" + thisToken
var allMessagesReceived = gapiGETRequest(gapiRequestInboxMessagesAndToken)
var allMessagesObject = JSON.parse(allMessagesReceived)
var messageIdsOfReceivedMessages = [];
var getIdsOfReceivedMessages = function(responseObject){
  for(var i=0; i < responseObject.messages.length; i ++) {
    messageIdsOfReceivedMessages.push(responseObject.messages[i].id);
  }
}

var messageContentsArr = [];
var getMessageContents = function(messageIdList)
{
  for(var i=0; i < messageIdList.length; i++)
  {
    var gapiRequestMessageWithId = "https://www.googleapis.com/gmail/v1/users/me/messages/" + messageIdList[i] + "?access_token=" + thisToken
    var currentMessage = JSON.parse(gapiGETRequest(gapiRequestMessageWithId))
    var encodedMessageContents = currentMessage.payload.parts[0].body.data
    var decodedMessageContents = atob(encodedMessageContents.replace(/-/g, '+').replace(/_/g, '/'));
    messageContentsArr.push(decodedMessageContents)
  }
}

getIdsOfReceivedMessages(allMessagesObject);
getMessageContents(messageIdsOfReceivedMessages);



回应



Response

推荐答案

<你正在收到完整的回复信息。当报告回复时,他们引用了原始信息,而原文的文本在回复信息中。您可能只想做Gmail和其他许多现代化的电子邮件应用程序,并折叠/隐藏任何以>开头的回复文本。

You are getting the full reply message. When the report replied, they quoted the original message and this the text of the original is in the reply message. You may just want to do what Gmail and many other modern emails apps do and collapse/hide any reply text which begins with >.

这篇关于如何在没有Gmail API原始邮件的情况下获取回复邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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