I need to iterate through every email within my project. I have more than 20000 mails. Therefore i read I need to use the restrict function. I found examples how to restrict to one specific domain
messages = messages.Restrict("@SQL=(urn:schemas:httpmail:SenderEmailAddress LIKE '%@domain.com')")
What do I need to use if have more than 100 domains or multiple (more than 100) Senders I want to use? Would it be a huge restrict function with logical OR connectors with all of the domains or can I input somehow a list into the restrict statement?
EDIT:
and i realized if i run a restrict function with this code, it just shows me with the len(messages) function that there are 0 emails while i can see a bunch of emails in outlook with used domain in the filter. what am i doing wrong?
CodePudding user response:
Typically you would need to use the logical OR
operator in the search string. Read more about that in the Filtering Items Using a String Comparison article. Also you may find the following articles helpful:
- How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder (C#, VB.NET)
- How To: Use Restrict method to retrieve Outlook mail items from a folder
But I would recommend handling each domain separately, so you will get Outlook running without freezes and will be able to process items in a logical bunch, especially when you have a hundred of domain names to search for.
CodePudding user response:
If you want to filter out internal senders and only process the senders outside your organization, check the SenderEmailType
property - it will be "EX"
for the internal senders (assuming you are using Exchange Server) and "SMTP"
for the external senders.