9
 import imaplib,time
 T=time.time()
 M=imaplib.IMAP4_SSL("imap.gmail.com")
 M.login(user,psw)
 M.select() 
 typ, data = M.search(None, 'UNSEEN SINCE T')
 for num in string.split(data[0]):
    try :
       typ, data=M.fetch(num,'(RFC822)')
       msg=email.message_from_string(data[0][1])
       print msg["From"]
       print msg["Subject"]  
       print msg["Date"]  
   except Exception,e:
      print "hello world"
M.close()
M.logout()

エラー:

Traceback (most recent call last):
File "mail.py", line 37, in <module>
 typ, data = M.search(None, 'UNSEEN SINCE T')
 File "/usr/lib/python2.7/imaplib.py", line 627, in search
 typ, dat = self._simple_command(name, *criteria)
 File "/usr/lib/python2.7/imaplib.py", line 1070, in _simple_command
 return self._command_complete(name, self._command(name, *args))
 File "/usr/lib/python2.7/imaplib.py", line 905, in _command_complete
 raise self.error('%s command error: %s %s' % (name, typ, data))
 imaplib.error: SEARCH command error: BAD ['Parse command error']

特定の時刻以降のメールを検索したい。これが私のコードです。しかし、エラーが発生します。解決方法についてアドバイスをいただけますか。どうもありがとうございました。

4

2 に答える 2