Delete message from Gmail “All Mail” folder via IMAP

浪子不回头ぞ 提交于 2019-12-11 08:38:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!