If this is on-prem, you can directly export to ST using New-MailboxExportRequest.
If this is online, you can use Search-Mailbox as indicated. However, Search-Mailbox will be deprecated in favor of New-ComplianceSearch. Using ExchangeLocation, and when search is finished, you can export results to a PST. Easiest is through the Purview (compliance) portal, or use New-ComplianceSearchAction -SearchName ... -Export -Format FxStream -ArchiveFormat SinglePst. Need to retrieve the exported PST through portal though.
Search for emails in mailbox
Hi, I need to search for emails in an user mailbox and then export these emails into pst file
It needs to have following
search of emails to be as follows,
All emails between User 1 and User 2
That include either in the subject, attachment name or body of the email the following names/terms
Word 1
Word 2
Between 02 Feb 2022 and 05 Mar 2022
What is the best way to do this, Do I need to use powershell to search mailbox or attached it to my outlook. (This mailbox is over 1.5TB)
I did try to use the search function but i'm not sure if this is the correct way or not
Search-mailbox -Identity ******@Domain.com -SearchQuery '(
(BODY:"Word 1" OR "Word 2" OR "Word 3")
OR
(Subject:"Word 1" OR "Word 2" OR "Word 3")
OR
(attachment:"Word 1" OR "Word 2" OR "Word 3")
)
AND
(
(FROM:User 1 OR User 2 OR User 3)
OR
(TO:User 1 OR User 2 OR User 3)
)
AND
(SENT:05/02/2022..07/03/2022)
' -TargetMailbox "******@domain.com" -TargetFolder "ProjectHamilton" -LogLevel Full -whatif
3 answers
Sort by: Most helpful
-
Michel de Rooij 1,541 Reputation points MVP
2022-06-28T11:00:57.223+00:00 -
KyleXu-MSFT 26,291 Reputation points
2022-06-29T03:41:46.253+00:00 Based on my testing, there exist some issue when use "Subject" and "Body" in the same search. So, I would suggest you create two search for them:
New-MailboxExportRequest -Mailbox UserA -ContentFilter "(Received -Gt '05/01/2018') -and (Received -lt '06/30/2022') -and ((Subject -like '*sub*') -or (Subject -like '*Test*'))" -FilePath "\\EXCH\Shared\1.pst" New-MailboxExportRequest -Mailbox UserA -ContentFilter "(Received -Gt '05/01/2018') -and (Received -lt '06/30/2022') -and ((Body -like '*body*') -or (Body -like '*test*'))" -FilePath "\\EXCH\Shared\2.pst"
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
-
Limitless Technology 39,811 Reputation points
2022-07-01T15:13:26.467+00:00 Hi Lalajee,
Greetings for the day! We are happy to help you regarding handling emails in user mailboxes.
Kindly try following options.
Option 1: The standard way to handle this is to allow a service to watch for the specific emails in the Mailbox.
Please try following steps.
- Create a console application which can read user mailboxes and watch for emails with specific condition. https://learn.microsoft.com/en-us/visualstudio/vsto/how-to-programmatically-search-within-a- specific-folder?view=vs-2022
- Host this stand alone exe in a windows scheduler job and have it to monitor the user mailboxes
- Once specific emails are received in user outlook, service can handle it and move it specific folder in an common mailbox that can be configured.
Option 2: If its an on premises exchange, please try using PowerShell scripts to handle this.
Try using "Search-Mailbox" command to move emails with specific condition.
Kindly verify details from below link,
https://learn.microsoft.com/en-us/powershell/module/exchange/search-mailbox?view=exchange-ps
Option 3: If you are trying to handle theses within your own mail box, try using "rules" part of outlook.
Outlook rule will have all the options you have requested and it can scan the emails which have already received in your mailbox.
Kindly look into following link,
Incase you need detailed steps with images, kindly verify this link -
https://www.vishalon.net/blog/move-outlook-emails-of-specific-date-range-to-a-folder
---------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer. --