gmail.js icon indicating copy to clipboard operation
gmail.js copied to clipboard

Observe.Before seems to return scrambled information

Open mrappard opened this issue 6 years ago • 3 comments

When I run the following code from the Github page it fails, both URL, body, data and xhr don't have anything similar to the format I would expect.

gmail.observe.before("send_message", function(url, body, data, xhr) {
  // lets cc this email to someone extra if the subject is 'Fake example'
  console.log('xxxxxx')
  if (data.subject == "Fake example") {
    if (body_params.cc) {
      if (typeof body_params.cc != "object")
        body_params.cc = [body_params.cc];
    } else {
      body_params.cc = [];
    }
    body_params.cc.push("[email protected]");
  }

  // now change the subject
  body_params.subject = "Subject overwritten!";

  console.log(
    "sending message, url:",
    url,
    "body",
    body,
    "email_data",
    data,
    "xhr",
    xhr
  );
});

mrappard avatar Jun 19 '19 22:06 mrappard

It’s a known error since new Gmail.

The only workaround I can think of is hijacking/intercepting the click event of the send button in the compose DOM.

josteink avatar Jun 20 '19 11:06 josteink

@mrappard @josteink The before send_messageevent is still showing scrambled body_params. What is a good way that you have tried for intercepting and changing the body before the email is sent?

stvhanna avatar Dec 22 '20 02:12 stvhanna

I only ever extract the full EML message upon send.

I never alter the message itself. With "new" Gmail, I don't think that's supported anymore, due to how Google changed the whole mail-sending process.

josteink avatar Dec 22 '20 14:12 josteink

Old issue is old. Closing.

josteink avatar Oct 11 '23 08:10 josteink