Can anyone tell me how I might be able to assemble an object that contains mail items from after a specific date from both my inbox and a specified folder of my inbox? I know how to get the items from each one separately, but I'm not sure how to combine them.
This is necessary due to the existence of an Outlook rule that moves messages to the folder, but it can only run when Outlook is open. Typically, the messages I need are in the folder, but if the rule hasn't run, I need to pick up messages from the general inbox too.
Here is what I have so far:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
root =outlook.Folders.Item(1).Folders('Inbox')
msg_fromdate= '09/03/2023'
filter_time = "[ReceivedTime]>="+"'"+msg_fromdate+" 12:00 AM" +"'"
inbox_messages = root.Items.Restrict(f'{filter_time}')
folder_messages = root.Folders('folder_name').Items.Restrict(f'{filter_time})
I need to iterate from message from both of these objects, but it would be easier to merge them into a single iterable object if that's possible.
Anyone have an idea?
You cannot do that - Outlook is not a relational database, you cannot create a join from two folders.
Nothing, however, prevents you from creating an array with the length equal to the sum of two collections and populating that array/list with items from two collections.