简体   繁体   中英

Not able to get mails from a certain folder in outlook in the order of their received date

python

outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder=outlook.Folders.Item("required folder")
mails=folder.Items
mail=mails.GetLast()
while(mail):
   print(mail.SentOn)
   mail=mails.GetPrevious()

not getting the mails in the order of their received date

output:

2019-10-27 07:54:44+00:00
2019-10-27 07:55:46+00:00
2019-10-25 14:17:07+00:00
2019-10-23 10:06:08+00:00
2019-10-24 09:33:07+00:00
2019-10-25 02:59:24+00:00

why the output is not in the order of their received date? while the mails in the outlook are in the order of their received date.

There is no order unless you explicitly call Items.Sort . Most likely you will get the items in their creation date, but it is not guaranteed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM