使用javax.mail搜索电子邮件收件箱 [英] Search email inbox using javax.mail

查看:86
本文介绍了使用javax.mail搜索电子邮件收件箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图查看是否有一种方法可以从javax.mail搜索电子邮件收件箱.说我想发送一个查询,并让它返回给我们的电子邮件.我们可以解析返回的HTML并提取数据吗?另外,如果上述可行,我将如何将该服务器返回的消息转换"为POP3消息?例如.我们提取了:

I was trying to see if there was a way to search an email inbox from javax.mail. Say I wanted to send a query and have the it return emails to us. Can we parse returned HTML and extract data. Also, if the above is possible how would I "translate" those messages returned by that server to POP3 messages? E.g. we have extracted:

Subject: Foo
Body: Bar

但是要使用POP3打开同一封邮件,我需要知道它是POP3 uid或数字.我认为我们无法获得UID,但也许我们可以弄清楚这个数字.

but to open same message using POP3 I need to know it's POP3 uid, or number. I don't think we'll be able to get UID but perhaps we can figure out the number.

我想问题是:

我可以将查询发送到电子邮件服务器(例如Hotmail或Yahoo)并获取返回的电子邮件吗?

Can I send a query to email server (such as Hotmail or Yahoo) and get returned emails?

推荐答案

不幸的是,POP3协议不支持它.它不像SQL那样.您需要自己将完整的邮箱镜像到某种数据存储区(SQL数据库?)中,然后在该存储库上执行搜索.您最终可以保留/缓存数据,这样就不必每次都检索整个收件箱,而只需检索未读的邮件.

Unfortunately, the POP3 protocol doesn't support that. It is not like SQL or so. You need to mirror the complete mailbox yourself in some kind of a datastore (SQL database?) and execute the search on that. You can eventually keep/cache the data so that you don't need to retrieve the whole inbox everytime, but only the unread items.

这篇关于使用javax.mail搜索电子邮件收件箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆