gmailgem / gmail

A Rubyesque interface to Gmail, with all the tools you'll need.
Other
397 stars 119 forks source link

Get message ID ? #241

Closed MathieuDerelle closed 6 years ago

MathieuDerelle commented 7 years ago

Is it possible to retrieve the message ID used in this API : https://developers.google.com/gmail/api/v1/reference/users/messages/get i.e. https://www.googleapis.com/gmail/v1/users/{userId}/messages/{id}

Gmail::Message#uid or msg_id dont do the job

solution : the ID in the rest api is the haxedecimal representation of msg_id (i.e msg_id.to_s(16))

unkrich commented 7 years ago

Not certain about this, but have you tried "variableName.message.id" without quotes?

unkrich commented 7 years ago

Take a look at #242

MathieuDerelle commented 7 years ago

It wasn't working even with this PR or that's what I thought:

By investigating a bit more, I've found out what's going on. This gem is giving the message_id as an integer : 1520524314001511398 and the API mentionned above is given it as an hexadecimal string : 1519fcceb86793e6 1520524314001511398.to_s(16) == 1519fcceb86793e6 # => true

edit: so the search with message_id is now working emails = @gmail.inbox.emails(message_id: 1520524314001511398)

march23 commented 7 years ago

do the search as message_id: integer_message_id.to_s(16) it will work

jparedesimx commented 7 years ago

email.message.message_id.to_s