Delete message from Gmail “All Mail” folder via IM

2019-08-14 07:03发布

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条回答
Viruses.
2楼-- · 2019-08-14 07:21

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.

查看更多
登录 后发表回答