1

I am creating a chrome addon for Gmail email tracker. For which I am using InboxSDK, I want to get all attachments from current Gmail compose body and I am using the following code.

composeView.addButton({
    .....
    onClick: function (event) {
       var cv = event.composeView;
       var mail_body = cv.getHTMLContent();
    });
});

As I am new to Chrome addon development as well as InboxSDK, I don't know how to get attachments from mail_body. Please, can anyone help me?

Thanks in advance.

Sunil Dora
  • 1,407
  • 1
  • 13
  • 26

1 Answers1

0

Try input[name="attach"] + a as a selector to fetch all the composes attachments links. From there you can go up in the DOM tree to get the root element for each attachment and do whatever you wanna do.

you could use document.querySelectorAll('input[name="attach"] + a'); for example. But that would return all the attachments links in all open compose views.

Here is an example with jquery, which then would just get the links from the given compose view.

composeView.addButton({
    .....
    onClick: function (event) {
       var cv = event.composeView;
       var mail_body = cv.getHTMLContent();
       var attachment_links = $(mail_body).find('input[name="attach"] + a');
    });
});