Prefetch preview text from JavaMail Message

后端 未结 1 1566
粉色の甜心
粉色の甜心 2021-01-19 11:07

I\'m using JavaMail 1.5.2 to read messages from IMAP accounts. To reduce the number of requests to the host I prefetch some message data, like From, Date, Message-ID etc.:

1条回答
  •  情歌与酒
    2021-01-19 11:30

    You have to retrieve the bodystructure first, then loop across the message structure, check the mime type of each part, and download the parts you want. IMAP lets you download all of the parts using one command, so if Javamail is a little smart, you should be able to do this with two IMAP commands, no matter how many bodyparts you end up wanting to download.

    The IMAP commands, if you're the type who likes to look at wire traffic, should be something like a uid fetch 234789 bodystructure followed by b uid fetch 234789 (body.peek[1.1] body.peek[2]).

    0 讨论(0)
提交回复
热议问题