javascript - 使用使用 inboxsdk 创建的自定义按钮发送邮件?
问题描述
我正在为 gmail 创建 chrome 扩展程序,我想在用户单击我的扩展程序创建的按钮时发送邮件。我正在使用 inboxsdk 来创建扩展。
我正在使用以下代码创建按钮
InboxSDK.load('1', '**************').then(function(sdk){
// the SDK has been loaded, now do something with it!
sdk.Compose.registerComposeViewHandler(function(composeView){
// a compose view has come into existence, do something with it!
composeView.addButton({
title: "button-title-goes",
iconUrl: 'https://image.ibb.co/mXS2ZU/images.png',
onClick: function(event) {
console.log( event );
event.composeView.insertHTMLIntoBodyAtCursor('<img src="https://image.ibb.co/mXS2ZU/images.png" alt="Smiley face" height="1" width="1">');
},
});
});
});
当用户单击此按钮时,我想发送邮件。
解决方案
如下使用撰写视图send()
功能。
sdk.Compose.registerComposeViewHandler(function(composeView){
composeView.addButton({
title: "button-title-goes",
iconUrl: 'https://image.ibb.co/mXS2ZU/images.png',
onClick: function(event) {
console.log( event );
event.composeView.insertHTMLIntoBodyAtCursor('<img src="https://image.ibb.co/mXS2ZU/images.png" alt="Smiley face" height="1" width="1">');
composeView.send();
},
});
});
您甚至可以交出允许您发送和存档的可选配置对象。 InboxSDK - ComposeView
推荐阅读
- authentication - .Net Core 身份验证和用户会话
- django - 何时使用 API 与 Django 内置函数
- php - curl_getinfo($ch, CURLINFO_CERTINFO) 为空
- python - 如何在 Python 中下载文件但忽略错误?
- java - 为什么我的 while 循环不读取这两个语句?
- flutter - 从链接启动时如何将数据传递给我的应用程序?
- angular - 同时运行 ng build --watch 和 ng serve 时,Angular 7 库 html-template 更改不会影响到应用程序
- c# - C# 在网络流上设置 WriteTimeout / ReadTimeout 没有区别?
- python - 在 Python 中连接字符串 - 什么是最快的方法
- r - 将一次开始的观察分布在多行上,直到另一次结束