我正在與 pywin32/win32com 合作,嘗試在我的收件箱中提取所有電子郵件的發件人資訊。我的代碼有效,但無論誰運行它,都只會顯示 1537 封電子郵件。我的收件箱默認檔案夾中有 2-3k 封電子郵件,一位同事的默認收件箱檔案夾中有近 20k 封電子郵件,但我們都運行此腳本,只看到相同的數字 1537。有人可以填寫我嗎至于什么可能導致這種限制?
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
rootlist = {}
inbox = outlook.GetDefaultFolder(6) #6 = Inbox (without mails from the subfolder)
messages = inbox.Items
PidTagSenderSmtpAddress = "http://schemas.microsoft.com/mapi/proptag/0x5D01001F"
for i in range(0, messages.Count):
messaging = inbox.Items[i]
if messaging.Class == 43 or messaging.Class == 69: #detect if mailitem
sender = messaging.PropertyAccessor.GetProperty(PidTagSenderSmtpAddress)
#print(sender)
if sender in rootlist:
rootlist[str(sender)][0] = rootlist[str(sender)][0] 1
else:
rootlist[str(sender)] = [1]
uj5u.com熱心網友回復:
永遠不要遍歷檔案夾中的所有專案,使用Items.Find/FindNext或Items.Restrict使用類似的查詢
@SQL="http://schemas.microsoft.com/mapi/proptag/0x5D01001F" = '[email protected]'
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/411758.html
標籤:
