Why attachments from Gmail drafts copied to Trash? - gmail

I use this Gmail API request for fetching Gmail messages in user mailbox. I need to list messages from Trash as well. But in some cases message list got by list messages request is different from actual content of Trash folder content.
To reproduce the problem next steps can be performed:
Ensure that my Trash folder is empty - no messages visible in Gmail web client and API list messages request returns 0 messages in Trash.
Start creating message by pushing "COMPOSE" button in Gmail web client.
Attach file to this draft message.
Get messages list in Trash using Gmail API list messages request.
The request returns 1 new message in user Trash folder (with the file attached to draft mentioned above) however it`s not visible in Gmail web client.
Is it normal or kind of bug? Is this a problem of Gmail web client or Gmail API?

Based from this thread, when you upload a file to Gmail as an attachment, Gmail creates a temporary file to hold the data and is then sent to Trash.
So, to get a more precise search, try adding q parameter using the advanced search syntax.
See Searching for Messages to learn more.

Related

Is it possible to send emails via GMAIL RESTful APIs without having a copy in Sent Folder?

Thank you all in advance.
Is it possible to send an email via the GMAIL RESTful API (https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=media) without saving a copy in the sent folder?
I have seen implementations in Outlook (Exchange/REST/Graph APIs) where emails can be sent without having copies in the sent folder. I was wondering if this is possible with the GMail APIs as well.
Again, thanks.
Workaround:
Currently, sending an email using Gmail API will always create a copy in the SENT folder, but one workaround you can do is:
Get the current timestamp timestamp before sending the message.
Send the message using messages.send.
Call users.messages.list with query parameter labelIds=SENT (note: this is case-sensitive) and ?q=in:sent after:<timestamp> to list the most recent sent message.
Call users.messages.delete and use the ID fetched from the previous call as the parameter.
References:
Method: users.messages.list
Method: users.messages.delete

Emails/drafts sent via Gmail REST API can't be opened in the new Gmail UI

When sending drafts via the Gmail REST API, the message in the "Sent Mail" folder can't be opened by the sender in the new Gmail UI. You get the error message "The conversation that you requested could not be loaded.".
The message on the recipient side can be opened without problem though, new UI or not.
Reverting to the old/classic Gmail UI allows the sender to open the sent message.
Steps to reproduce:
Compose a draft in Gmail (new or old UI doesn't matter)
Find the draft ID via GET https://www.googleapis.com/gmail/v1/users/me/drafts
Send the draft via POST https://www.googleapis.com/gmail/v1/users/me/drafts/send with body {"id": "<draftId>"}
Go back to Gmail and switch to the new Gmail UI, then attempt to open the recently sent draft in the Sent folder. Attempting to open the message will fail.
Revert to the old/classic Gmail UI and open the recently sent draft in the Sent folder. You will be able to open the message without issues.
The recipient will be able to open the message without issues, using either the new or old UI.
UPDATE
When the broken sent email receives a reply, it seems to get 'fixed' and the sender can now open the sent email from the new Gmail UI. This seems to suggest that the REST API is missing something that gets fixed once the thread is updated by other means?
The error message in the browser console when attempting to open the broken sent message:
Error: Ppa No message loaded when we received the DETAILED_CONVERSATION_MESSAGES_LOADED event.
I can't reproduce this. Note that in the reproduction steps #2 is unnecessary. Instead, the result of drafts.create() in #1 should be analyzed, the id of the new draft message is present there.
Also worth noting, Draft IDs are not the same as Message IDs. The response of drafts.create() and drafts.update() will be a Draft ID while the result of drafts.send() will be the message ID. When viewing the sent message in Gmail UI make sure you are using the message ID.

No user messages on Chatbase transcripts

I've been trying to take advantage of the Transcripts feature in Chatbase, but whenever I open a transcript all the user messages are shown as (No content).
The messages sent by the bot are all shown properly and the order of the messages is correct as well (both user and bot). On the messages report tab I can see the user messages so they are being sent across properly.
I'm sending all the messages using the generic message API, with the original text on the message field.
This has been happening consistently for me on all projects, so I'm probably doing something wrong..any ideas?
I work on Chatbase and would be happy to look into your issue. If you could please contact chatbase-support#google.com and provide the api key, the name of the bot, or the email address you used to create the account I will be happy to look into the issue for you.

How to scan ALL mail via Gmail API?

After I OAuth my google account I can connect to it via the IMAP protocol. Listing folders lists all the "labels" plus "[Gmail]" which isn't selectable.
Is there any way to list ALL mail and/or at least get into the trash? Also what about archived - those don't show up in the INBOX folder
I did some digging around and tried this:
var_dump($storage->getFolders('[Gmail]'));
which doesn't list anything... but this does:
var_dump($storage->getFolders('[Gmail]/Trash'));
How can I list all those folders
[Gmail]/All Mail contains all of your messages in Gmail, including your sent and archived messages. Any messages that you see in your inbox will also appear in the [Gmail]/All Mail folder.

How to move message to Trash in gmail imap?

I am creating an application in which I need to delete mail using IMAP in gmail. But when I set the flag to delete the message moves to spam folder instead of trash or directly deletion. Is there any way to move message to trash?
UPDATE
Now my messages are moving from inbox to important folder. I'm sending message to my self( in web browser) and it's marked as important by default.
There is a Google support site that says "Do NOT save deleted messages to your [Gmail]/Trash folder because this will delete a message in all folders." - so you might want to do exactly that :)
Adding onto flob's answer
the following folder paths works too
it seems like it's depending on when the user sign up for gmail
"[Gmail]/Trash"
"[Google Mail]/Bin"
"[Gmail]/Bin"

Resources