0
我有一個程序,顯示我最近從Outlook電子郵件。如果我在程序運行時收到新電子郵件,它不會刷新並顯示新電子郵件。有關我如何做到這一點的任何建議?如何使用win32com Outlook在Python中刷新電子郵件?
我的代碼沒有更新到最新的電子郵件:
import win32com.client
import os
import threading # use the Timer
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
messages = inbox.Items
message = messages.GetLast()
body_content = message.Body
def timer():
print (body_content)
threading.Timer(30, timer).start()
timer()