gmail.js
gmail.js copied to clipboard
How to stop Gmail from sending an email?
Hi, I have a before.send_message observe function that performs some business logic. Is there a way to cancel the sending of the email based on the business logic and show the compose window again?
gmail.observe.before("send_message", function (url, body, data, xhr) {
if (gmail.check.is_google_apps_user()) {
var emailId = data[1];
var from = {'name': data[2][3], 'email': data[2][2]};
var to = _.map(data[3], (d) => ({'name': d[3], 'email': d[2]}));
var cc = _.map(data[4], (d) => ({'name': d[3], 'email': d[2]}));
var bcc = _.map(data[5], (d) => ({'name': d[3], 'email': d[2]}));
var subject = data[8];
var content = data[9];
//perform some business logic and possibly cancel the sending and show the compose window again.
}
});
After Gmail transitioned to the new data-model, I don't think there's any way to prevent sending any more. Someone please correct me if I'm wrong.
Either way, as far as I know, only after.send_message is now meaningfully supported.
Old issue is old. Closing.