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?
In order to retrieve the the ID of the attachments of a certain message, you would have to get the message resource via Users. messages. get, and from that response, retrieve the ID of the attachment.
Steps to Configure Attachment Compliance in GmailScroll down to find Gmail and click on it. Scroll down to Advanced settings and click on it. Scroll down to Attachment compliance and hover on it and to see configure option and click on it. Select the messages that you want to affect.
php'; $client = new Google_Client(); $client->setClientId($this->config->item('gmailapi_clientid')); $client->setClientSecret($this->config->item('gmailapi_clientsecret')); $client->setRedirectUri(base_url('auth')); $client->addScope('email'); //$client->addScope('profile'); $client->addScope('https://mail.google.com' ...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With