0
내 Gmail 계정에있는 모든 이메일 제목을 나열하고 싶습니다.GMail에있는 모든 이메일 제목을 나열하는 방법은 무엇입니까?
import imaplib
import email
user="xxxx"
password="yyyy"
con=imaplib.IMAP4_SSL('imap.gmail.com')
con.login(user,password)
num=int(con.select("[Gmail]/&YkBnCZCuTvY-")[1][0])
의 num은 1200, 내 Gmail 계정에 1,200 이메일이있다. 내가 처음 이메일 제목을 얻기 위해 원하는 모든 이메일 subject.If을 나열 할
result,data=con.fetch(b'1', '(RFC822)')
print email.message_from_string(data[0][1])["Subject"]
두 개의 라인을 얻을 수 있습니다. 하지만 이메일 제목을 다음과 같이 모두 나열 할 수는 없지만 해결 방법은 무엇입니까?
for item in range(num+1):
result,data=con.fetch(str(item), '(RFC822)')
print email.message_from_string(data[0][1])["Subject"]