也许今天我脑子坏了,但是我突然想不出如何用
ruby的net / imap库读取邮件.我已经呆了好几个小时.我将“ruby imap read body”的几个变体输入到google中,并且已经探索了许多网站.所有这些都有关于如何拉附件,同步电子邮件服务器,使用gmail等的示例…有些(如chilkat)实际上是为您实现的共享软件库.我看过net / imap文档,尽管除了阅读正文外,还有几个例子.
我以前使用过net / imap,但是我只需要将一个收件箱中的附件下拉到目录.我在#ruby和#rubyonrails中询问无效 – 没有人可以弄清楚.
imap=Net::IMAP.new('mail.xks.com') #of course these are not real imap.login('web1_xk3','pxx2006') imap.select('INBox') imap.search(["SENTSINCE",(Time.now-1.day).strftime("%d-%b-%Y")]).each do |msgid| body = imap.fetch(msgid,"BODY")[0].attr["BODY"] ##insert code for getting the text from the body here ##body.class is BodyTypeText end