如何使用C#仅从收件箱中获取未读邮件?
我需要从收件箱中收到未读的电子邮件-处理退回邮件.
我不需要完整的消息.我只需要:仅来自未读电子邮件的主题和正文.
我可能必须使用IMAP,因此可以向我推荐一个开源"的好解决方案吗?这样我就可以毫无问题地出售该软件了吗?
但是,当smtp服务器不支持IMAP时,我必须使用POP3吗? 那个项目对此有好处吗?或者,也许还有其他更好的方法?
感谢您的帮助,
-------------------------------------------------- ---------------------------------------------
更新:
我有一个主意.
我可以阅读收件箱中有多少封邮件.所以,我也可以拿到最后一个.
我可以检查计时器中是否有退回消息(例如每5分钟一次).我可以一一收到消息,然后检查日期.如果消息是在5分钟前发送的,我会中断.
在这种解决方案中,我不会每次都从收件箱中收到所有邮件.那是一个好的解决方案吗?
我的想法的伪代码:
Hi, I need to get unread emails from my inbox - to handle bounce-backs messages.
I don''t need to get entire message. What I need is only: Subject and body only from unread e-mails.
I probably have to use IMAP, so could recommend me an "open-source" and good solution? so I can sell this software without any problems?
But, when smtp server don''t support IMAP, I have to use POP3? That project will be good for that? Or maybe there is some other, better way ?
Thanks for help,
-----------------------------------------------------------------------------------------------
UPDATE:
I''ve got an idea.
I can read how many messages are in inbox. So, I also can get the last one.
I can check if there is a bounce-back message in timer (every 5 minutes for example). I could get messages one by one, and check the date. If the message was sent before 5 min ago, i would break.
In that solution, I will not get all messages from an inbox every time. Is that good solution ?
The pseudo-code of my idea:
TIMER( Tick every 5minutes )
{
(LOCK)
loop(on inbox from end to begin)
{
// If the message date is older then "5 minutes ago" break
if (message date < DateTime.Now.AddMinutes(-5);)
{
if (the subject is "Undelivered Mail Returned to Sender")
{
// Here I will parse message so that I will know the addresse
// And removie that addresse from my list.
}
}
else
break;
}
(UNLOCK)
}
POP3无法跟踪未读电子邮件.如果您的服务器不支持IMAP,请尝试使用Outlook自动化.
Outlook集成 [ microsoft.office.interop.outlook._documentitem.unread.aspx [ ^ ]
POP3 does not have the capability to track unread emails. If your server does not support IMAP you try to use outlook automation.
Outlookintegration[^]
microsoft.office.interop.outlook._documentitem.unread.aspx[^]