Send mail using custom button created using inboxsdk?

孤街醉人 提交于 2019-12-11 17:53:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!