1

I have replaced the "Send" button in the compose dialog with my "Send" button and using "Gmail API" to send the email.

I am able to send the email and get the response.

Now to make it more user-friendly, I want to close the compose dialog after my email is sent (similarly when the Gmail closes the dialog when email is sent). But I am unable to do so.

NOTE: When the email is sent successfully using "Gmail API", I am deleting the draft for that email also.

UPDATE:

Using JQuery, I get the "X" (Close) element in the dialog which is an image-

<img class="Ha" id=":2i" src="images/cleardot.gif" alt="Close" aria-label="Save &amp; Close" data-tooltip-delay="800" data-tooltip="Save &amp; Close">

I want to trigger a click event on it but it is not triggering.

When I tried triggering the click event on the "Discard" button of the same dialog, it worked successfully. Here is the discard button-

<div id=":68" class="oh J-Z-I J-J5-Ji T-I-ax7" tabindex="1" role="button" data-tooltip="Discard draft" aria-label="Discard draft" style="user-select: none;">

How do I click on the img tag?

Pallavi Goyal
  • 536
  • 1
  • 4
  • 21
  • As a workaround - it's possible to get the "id" of the "cancel" button (or do whatever happens after clicking the original "send" button) via css-selector and trigger the "click" event. – Pavel Sapehin Aug 14 '18 at 07:39
  • I tried using css-selectors but unable to find a proper solution. – Pallavi Goyal Aug 14 '18 at 08:19
  • 1
    As far as I can see Gmail is built using the "Closure" internal framework. You may need to look into an internal implementation and see how to "intrude" into it (see how events are working, how to react to them). See: https://stackoverflow.com/questions/19273795/which-front-end-technology-is-gmail-using – Pavel Sapehin Aug 14 '18 at 08:58
  • 1
    Also this related topic may help https://stackoverflow.com/questions/23174710/how-to-develop-chrome-extension-for-gmail?rq=1 – Pavel Sapehin Aug 14 '18 at 09:01
  • Thank you @PavelSapehin I will look at the references :) – Pallavi Goyal Aug 14 '18 at 09:16

1 Answers1

0

You can take help of inbox sdk. It works perfectly.

sdk.Compose.registerComposeViewHandler( (composeView) => {
    composeView.on('presending', function (event) {
        //do anything you want to
        composeView.close(); // this will close the compose window
})

Before gmail sends mail itself, you can send the mail using gmail api as you are doing and then this will close the compose window and save the draft. As you have integrated your own send button, you will need to use the library accordingly.

Karan Shah
  • 111
  • 11