MailKit从Gmail中删除单个邮件 [英] MailKit Delete single message from gmail
问题描述
我使用MailKit( https://github.com/jstedfast/MailKit )连接到谷歌应用程序通过IMAP,我怎么可以删除一条消息? (我很好,它已经转移到垃圾箱,只需要它的收件箱。
到目前为止,我已经连接,下载,解析消息体的链接。只需要这一个最后一个动作来获得我所需要的东西。
谢谢!
要从IMAP服务器上的文件夹中删除邮件,您只需要这样做:
客户端。 Inbox.AddFlags(new int [] {index},MessageFlags.Deleted);
或
client.Inbox.AddFlags(new UniqueId [] {uid},MessageFlags.Deleted);
现在邮件标记为\在服务器上删除。
然后您就可以通过调用清除所有已删除项目的文件夹:
client.Inbox.Expunge();
$ c如果您使用的是UID而不是索引,并且IMAP服务器支持UIDPLUS扩展(检查client.Capabilities),则可以将exp取消只是一组选定的消息,如下所示: if(client.Capabilities.HasFlag(ImapCapabilities.UidPlus))
client.Inbox.Expunge(new UniqueId [] {uid});
I am using MailKit (https://github.com/jstedfast/MailKit) to connect to google apps via imap, how can I delete a single message though ? (I am fine to have it moved to trash, just need it out of the inbox.
So far I have it connected, downloading, parsing links from message bodies. I just need this one last action to have what I need.
Thanks!
解决方案 To delete a message from a folder on the IMAP server, this is all you need to do:
client.Inbox.AddFlags (new int[] { index }, MessageFlags.Deleted);
or
client.Inbox.AddFlags (new UniqueId[] { uid }, MessageFlags.Deleted);
Now the message is marked as \Deleted on the server.
You can then purge the folder of all deleted items by calling:
client.Inbox.Expunge ();
If you are using UIDs instead of indexes and the IMAP server supports the UIDPLUS extension (check the client.Capabilities), you can expunge just a selected set of messages like this:
if (client.Capabilities.HasFlag (ImapCapabilities.UidPlus))
client.Inbox.Expunge (new UniqueId[] { uid });
这篇关于MailKit从Gmail中删除单个邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!