Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition
by Jonas Andersson, Nuno Mota, Mike Pfeiffer
How it works...
The code in this example is very similar to what we used in the recipe for Searching mailboxes. Again, since we are not supplying credentials when creating the ExchangeService object and we're not using impersonation, the search will be performed in the administrator mailbox. When calling the FindItems method, we're specifying the folder to search, the AQS search query to be used, and the item view.
As you can see, we're using the Attachment property in the AQS query. This allows us to search for a string within the filename or inside the file itself. When the results are returned, we loop through each message, and use the Load method to load the attachment, which allows us to then access the Content property of each attachment. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access