Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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
Javascript 应用程序脚本-Gmail插件-在Gmail消息中获取所选文本_Javascript_Google Apps Script - Fatal编程技术网

Javascript 应用程序脚本-Gmail插件-在Gmail消息中获取所选文本

Javascript 应用程序脚本-Gmail插件-在Gmail消息中获取所选文本,javascript,google-apps-script,Javascript,Google Apps Script,我正在开发一个Gmail插件,需要通过GoogleApps脚本在Gmail消息中获取选中/突出显示的文本。我可以通过下面的代码获取整个消息体,但似乎找不到获取所选文本的方法 function onGmailMessage(e) { // Get the ID of the message the user has open. var messageId = e.gmail.messageId; // Get an access token scoped to the curren

我正在开发一个Gmail插件,需要通过GoogleApps脚本在Gmail消息中获取选中/突出显示的文本。我可以通过下面的代码获取整个消息体,但似乎找不到获取所选文本的方法

function onGmailMessage(e) {

  // Get the ID of the message the user has open.
  var messageId = e.gmail.messageId;

  // Get an access token scoped to the current message and use it for GmailApp
  // calls.
  var accessToken = e.gmail.accessToken;
  GmailApp.setCurrentMessageAccessToken(accessToken);

  // Get the subject of the email.
  var message = GmailApp.getMessageById(messageId);
} 
使用Gmail API/Apps脚本无法在服务器端获取客户端选定的Gmail消息文本 当触发时,Gmail插件可以为您提供以下信息:

  • gmail.accessToken
  • gmail.b客户[]
  • gmail.ccRecipients[]
  • gmail.messageId
  • gmail.threadId
  • gmail.toRecipients[]
Gmail包含以下信息:

{
  "id": string,
  "threadId": string,
  "labelIds": [
    string
  ],
  "snippet": string,
  "historyId": string,
  "internalDate": string,
  "payload": {
    object (MessagePart)
  },
  "sizeEstimate": integer,
  "raw": string
}
因此,此信息仅适用于已保存的已发送/已接收邮件或已保存的草稿

不幸的是,Gmail加载项(与Docs加载项不同)无法访问草稿模块中客户端键入/选择的文本


如果这个特性对于你的应用程序来说是至关重要的,你需要改变方向,例如考虑一个Chrome扩展,用HTML或JavaScript来处理客户端内容是可能的。你是指用户在浏览器的用户界面上阅读信息时手动选择的文本?是的,当我们在gmail信息中手动选择文本时。