# Subject filter with outlook in Powershell

**URL:** <https://forums.powershell.org/t/subject-filter-with-outlook-in-powershell/18117>\
**Category:** PowerShell Help\
**Created:** [December 5, 2021, 10:02am UTC](https://forums.powershell.org/t/subject-filter-with-outlook-in-powershell/18117 "2021-12-05T10:02:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shantanu\_Gupta](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Shantanu\_Gupta](https://forums.powershell.org/u/Shantanu_Gupta)\
**Post date:** [December 5, 2021, 10:02am UTC](https://forums.powershell.org/t/subject-filter-with-outlook-in-powershell/18117/1 "2021-12-05T10:02:17Z")

</div>

I am saving outlook attachments with PowerShell. I have followed all his instructions that he has written in his blog. [Saving Outlook attachments with PowerShell - Mikey Bronowski - Blog](https://bronowski.it/blog/2020/09/saving-outlook-attachments-with-powershell/)  
Also it is working.  
Only thing I can’t figure it out how I used subject filter to filter certain emails will be downloaded as email attachments.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [December 7, 2021, 10:41pm UTC](https://forums.powershell.org/t/subject-filter-with-outlook-in-powershell/18117/2 "2021-12-07T22:41:58Z")

</div>

Do you have the modified code that you’ve tried? You can sanitise it to remove your e-mail address and any personal information.

Mail items have a `Subject` Property so in the `foreach ($email in $emails)` loop, you should be able to use something like `Where-Object {$email.Subject -eq 'Test Message'}` to filter the messages by subject.

If you can clarify exactly how you’re trying to filter the messages and provide some example code, we might be able to help in a bit more detail.

When posting the code, please remember to use the pre-formatted text button **\</\>** and paste the code inbetween the backticks. It really helps us with readability and copying and pasting code for testing.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:20pm UTC](https://forums.powershell.org/t/subject-filter-with-outlook-in-powershell/18117/3 "2024-05-16T20:20:11Z")

</div>


