gmail.new.get.email_data returns null when compose is passed to it as parameter
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])
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 I'm trying to get from, to, cc, bcc and email body.
The compose-instance has methods for getting and setting that.
Read the documentation/readme and fool around interactively. It should be dead easy.
@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?
It's in the readme:

@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]"}]
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.
Also, compose-emails have not been normalised. You will have to do that manually.
@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 :)
PRs welcome 😉
This issue is old and has seen no activity in a year+.
Closing this issue.