我正在寻找使用IMAP获取消息大小的最佳方法(我正在为自己编写一个简单的c#lib)。基本上POP3 STAT命令等效是好的,但它不存在。我正在考虑获取邮件标题并获取内容长度字段。任何人都有更好的想法或解决方案?
答案 0 :(得分:2)
也许使用FETCH NNN HEADER
是唯一的方法。你检查过FETCH NNN RFC822.SIZE
的规格了吗?也许一个好主意是学习fetchmail
日志:
fetchmail: IMAP< * OK GroupWise IMAP4rev1 Server Ready
fetchmail: IMAP> A0001 CAPABILITY
fetchmail: IMAP< * CAPABILITY IMAP4rev1 AUTH=XGWTRUSTEDAPP XGWEXTENSIONS
fetchmail: IMAP< A0001 OK CAPABILITY completed
fetchmail: IMAP> A0002 LOGIN "user1" *
fetchmail: IMAP< A0002 OK LOGIN completed
fetchmail: IMAP> A0003 SELECT "INBOX"
fetchmail: IMAP< * 260 EXISTS
fetchmail: IMAP< * 1 RECENT
fetchmail: IMAP< * OK [UNSEEN 260]
fetchmail: IMAP< * OK [UIDVALIDITY 1301053702]
fetchmail: IMAP< * OK [UIDNEXT 545]
fetchmail: IMAP< * FLAGS (Answered Flagged Deleted Draft Seen)
fetchmail: IMAP< * OK [PERMANENTFLAGS (Answered Flagged Deleted Draft Seen *)]
fetchmail: IMAP< A0003 OK [READ-WRITE] SELECT completed
fetchmail: IMAP> A0004 SEARCH UNSEEN NOT DELETED
fetchmail: IMAP< * SEARCH 260
fetchmail: IMAP< A0004 OK SEARCH completed
260 messages (259 seen) for user1 at host_address.
skipping message user1@host_address:1 not flushed
{ ... etc ... }
skipping message user1@host_address:258 not flushed
skipping message user1@host_address:259 not flushed
fetchmail: IMAP> A0005 FETCH 260 RFC822.SIZE
fetchmail: IMAP< * 260 FETCH (RFC822.SIZE 23853)
fetchmail: IMAP< A0005 OK FETCH completed
fetchmail: IMAP> A0006 FETCH 260 RFC822.HEADER
fetchmail: IMAP< * 260 FETCH (RFC822.HEADER {367}
fetchmail: IMAP< )
fetchmail: IMAP< A0006 OK FETCH completed
fetchmail: IMAP> A0007 FETCH 260 BODY.PEEK[TEXT]
fetchmail: IMAP< * 260 FETCH (BODY[TEXT] {23486}
(23486 body octets) *********************
fetchmail: IMAP< A0007 OK FETCH completed
fetchmail: IMAP> A0008 STORE 260 +FLAGS (Seen)
fetchmail: IMAP< * 260 FETCH (FLAGS (Seen Recent))
fetchmail: IMAP< A0008 OK STORE completed
fetchmail: IMAP> A0009 LOGOUT
fetchmail: IMAP< * BYE IMAP4rev1 Server Disconnect
fetchmail: IMAP< A0009 OK LOGOUT completed