问题
I am accessing Gmail All Mail folder via imap, using RFC 3501. I need to delete a message (Move to Trash or Permanently delete) from the folder. The following commands do not seem to work:
UID STORE 123 +FLAGS (\Deleted)
EXPUNGE
I can modify labels using X-GM-LABELS, but there is no option to add a "Trash" label.
The RFC 3501, does not have a "MOVE" command, so I need to copy the message to "Trash" folder and then remove it from the parent folder. What's the way out??
Thanks.
Found partial answer.
To set Trash as a label, we need to use "\\Trash" as the label. Here are the commands to move the message to trash (delete inbox label and add trash label).
UID STORE 123 -X-GM-LABELS (\\Inbox)
UID STORE 123 +X-GM-LABELS (\\Trash)
Now, I am stuck on how to delete the message permanently.
回答1:
These commands delete the message permanently:
// sequence number 123, 234 are the same message in different folders
SELECT "[Gmail]/AllMail"
COPY 123 "[Gmail]/Trash"
CLOSE
SELECT "[Gmail]/Trash"
STORE 234 +FLAGS (\Deleted)
EXPUNGE
Just tried it out and it works.
来源:https://stackoverflow.com/questions/10783109/delete-message-from-gmail-all-mail-folder-via-imap