简体   繁体   English

C#:如何跟踪文件夹之间消息的 UID?

[英]C#: How to keep track of the UID of messages between folders?

I'm moving messages from the inbox folder to a new folder.我正在将邮件从收件箱文件夹移动到新文件夹。 After a while I need to move some of these messages(not all) to a new folder.过了一会儿,我需要将其中一些消息(不是全部)移动到一个新文件夹中。 The problem with this is that everytime I move a message the uid changes.问题在于,每次我移动消息时,uid 都会发生变化。 How can I do this without moving the wrong message?我怎样才能在不移动错误消息的情况下做到这一点?

If your server supports UIDPLUS (nearly all do), and you yourself are moving or copying the messages, the server will give you the new UID when you copy or move it in the COPYUID response.如果您的服务器支持 UIDPLUS(几乎所有都支持),并且您自己正在移动或复制邮件,那么当您在 COPYUID 响应中复制或移动它时,服务器会为您提供新的 UID。 You'll need to record this.你需要记录这个。

An example from the IMAP MOVE RFC6851:来自 IMAP MOVE RFC6851 的示例:

   C: a UID MOVE 42:69 foo
   S: * OK [COPYUID 432432 42:69 1202:1229]
   S: * 22 EXPUNGE
   S: (more expunges)
   S: a OK Done

The COPYUID response includes the UIDVALIDITY of the destination mail box, the UID set of the source messages, and the UID set of the destination messages. COPYUID响应包括目标邮箱的UIDVALIDITY 、源消息的 UID 集和目标消息的 UID 集。

If some other process is doing the moving, there's no way to guarantee the same message, and you'd have to track them based on their content (eg, the Message-ID header, the date time, a hash, etc.)如果其他进程正在移动,则无法保证相同的消息,并且您必须根据它们的内容来跟踪它们(例如,消息 ID header、日期时间、hash 等)

You're "moving" also involves an INSERT into DB to keep track of UIDs?您正在“移动”还涉及插入数据库以跟踪 UID? If yes, watch for autogenerated PKs.如果是,请注意自动生成的 PK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM