Forum Discussion
Julian-K
4 years agoRegular Visitor
Search Email Subject For Keywords, But Foldable
Hi! I want to search a mailbox (Microsoft Exchange) for mails with certain keywords in the subject. Mailbox = Exchange.Contents("[email protected]"),
Mails = Mailbox{[Name="Mail"]}[Data],
...
- 4 years ago
I'm not sure if it's possible to write the M for this so that it folds into a native Exchange query. You might need to at least download all of the Subject lines.
I'm not sure if something like this will work but it might be worth a try.
Mails = Exchange.Contents("[email protected]"){[Name="Mail"]}[Data], Keywords = List.Buffer(Keywords[Column1]), Subjects = List.Buffer(List.Distinct(Mails[Subjects])), FilteredSubjects = List.Buffer( List.Select( Subjects, (S) => List.AnyTrue( List.Transform(Keywords, each Text.Contains(S, _)) ) ) ), Filtered = Table.SelectRows(Mails, each List.Contains(FilteredSubjects, [Subject]))Note that FilteredSujects might need to be a separate query and you just use the first and last lines of the above to attempt to create a foldable query.
Anonymous
4 years agoNot applicable
Instead of using a custom function try storing your keywords as a list (an actual list query), and then instead of each Text.Contains, use Table.SelectRows(TableOrPriorStepName, each List.Contains(List.Distinct(List.Buffer(ListQueryName)), [Subject]))
That might speed it up--and might speed it up more than 100x. Plus it will fold.
--Nate