Reputation: 133
I was under the assumption that each attachment for a given message will have a unique attachmentId that I could use to reference that attachment when needed. Seems this assumption is incorrect.
Each time you call the Users.messages.get service for Google's GMail API ( https://developers.google.com/gmail/api/v1/reference/users/messages/get ) to retrieve a message that has an attachment, the returned attachmentId is different even though the same messageId was used. How would I find the "real" attachmentId?
Upvotes: 11
Views: 3018
Reputation: 46
To others who may have this question, we were able to get to someone in Google who provided the following info:
Hopefully others will also find this useful.
Upvotes: 3
Reputation: 111
I have myself had to store attachment ids in database, and I am not even yet sure if both of my options below are indeed persistent. My tests over several weeks while working on it seems to suggest it however, but I cannot guarantee it.
Use a key based on threadid, messageid and partid for the attachment.
Take a look at the MessagePartHeader for an 'X-Attachment-Id' value. These id's is what I currently use for storing attachment ids.
Upvotes: 1