问题
I am creating chrome extension for gmail, I want send a mail when user click a button created by my extension. I am using inboxsdk for creating extension.
I am creating button using following code
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">');
},
});
});
});
I want to send mail when user click on this button.
回答1:
Use the compose views send()
function like follows.
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();
},
});
});
You can even hand over an optional configuration object which allows you to send and archive. InboxSDK - ComposeView
来源:https://stackoverflow.com/questions/52813263/send-mail-using-custom-button-created-using-inboxsdk