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

gmail.new.get.email_data returns null when compose is passed to it as parameter

Open markon1 opened this issue 5 years ago • 10 comments

I want to get email_data of compose email, but whenever I call gmail.new.get.email_data with compose as a parameter it returns null.

I tried doing it like this:

gmail.observe.on('compose', function(compose, composeType) {
  gmail.new.get.email_data(compose);
});

and like this:

gmail.new.get.email_data(gmail.dom.composes()[0])

markon1 avatar Jun 27 '20 00:06 markon1

Getting email-data from a compose-instance is not supported, because technically speaking it's not an email yet.

What exactly are you trying to accomplish? There might be workarounds.

josteink avatar Jun 27 '20 09:06 josteink

@josteink I'm trying to get from, to, cc, bcc and email body.

markon1 avatar Jun 27 '20 14:06 markon1

The compose-instance has methods for getting and setting that.

Read the documentation/readme and fool around interactively. It should be dead easy.

josteink avatar Jun 27 '20 17:06 josteink

@josteink I just want to be able to request current compose email and get its to, cc, bcc and email body. I'm reading docs for days and fiddling around, but I can't come to terms with it. It should be a straight forward use case, can you help me please?

markon1 avatar Jun 27 '20 18:06 markon1

It's in the readme:

image

josteink avatar Jun 27 '20 19:06 josteink

@josteink I know about that, but how can I get the currently active compose if there are multiple compose windows open?

Also, calling to(), cc(), bcc() returns them in this format: [""[email protected]" <[email protected]>", "SomeName <[email protected]>"]

Is there a function which would return it like an array of objects, like email_data does? [{name: "SomeName", address: "[email protected]"}]

markon1 avatar Jun 27 '20 19:06 markon1

There is only a method to return an array of all open composes, and no such concept of an "active" one.

If you need to create such a concept, it might make more sense to monitor the compose-related events for when one is opened, and the relevant compose-instance is passed along as a event-handler parameter.

It's all there in the documentation.

josteink avatar Jun 27 '20 20:06 josteink

Also, compose-emails have not been normalised. You will have to do that manually.

josteink avatar Jun 27 '20 20:06 josteink

@josteink I see, it's a shame but thanks for confirming so I don't need to break my head looking for existing method I thought exists :)

markon1 avatar Jun 27 '20 20:06 markon1

PRs welcome 😉

josteink avatar Jun 27 '20 20:06 josteink

This issue is old and has seen no activity in a year+.

Closing this issue.

josteink avatar Oct 12 '23 07:10 josteink