Avatar of Gospodin Rasputin
Gospodin Rasputin
 asked on

Deleting an e-mail sent to all users from exchange 2007

Someone has just mistakenly sent an e-mail to all users. Is there anyway I can remove all unread copies of this e-mail before the weekend is over?

I know I could attempt to reacall/replace the e-mail, but I'm afraid this depends on the recipient agreeing to the recall. Is there a way my Exchange admins can remove this message from the Exchange Information Store using the message ID?

Thanks
ExchangeOutlookEmail Servers

Avatar of undefined
Last Comment
Gospodin Rasputin

8/22/2022 - Mon
Will Szymkowski

You can use the Export-Mailbox cmdlet to accomplish this. See the below script...
Get-Mialbox -ResultSize "Unlimited" |
Export-Mailbox -PSTFolderPath "C:\pstfiles\filename.pst" -BadItemLimit 1000000 -ContentKeywords "CLICK HERE TO Upgrade" -DeleteContent -Confirm:$false

Open in new window


The above script will get all mailboxes and export the results to a pst file and delete the email from all of the mailboxes where "Click Here To Upgrade" is in the body or the subject line.

Will.
Amit

In 2007, you can use export-mailbox cmd let to search and delete specific email. Here is MS KB with all required steps:
http://blogs.technet.com/b/exchange/archive/2010/10/27/3411398.aspx
Gospodin Rasputin

ASKER
Hi Amit,
I'm using the following but it seems to be complaning because I have not specified thethe target mailbox.

Get-Mailbox -ResultSize Unlimited | Export-Mailbox -ContentKeywords "REC_2999.wmv" -StartDate "15/06/2010" -EndDate "18/06/2010" -DeleteContent

But I wish to just remove the message without copying it to anywhere else.

Any idea? I suspect maybe I should remove the |Export -Mailbox from the command.

The error I get on all the mailboxes is as follows:

Export-Mailbox : Error was found for Udojil Alexander (Udojil.Alexander@mydomain.o
rg.uk) because: Error occurred in the step: Moving messages. Failed to copy messages to the destination mailbox store with error:
MAPI or an unspecified service provider.
ID no: 00000000-0000-00000000, error code: -1056749164
At line:1 char:51
+ Get-Mailbox -ResultSize Unlimited | Export-Mailbox <<<<  -ContentKeywords "RE
C_2999.wmv" -StartDate "15/06/2010" -EndDate "18/06/2010" -DeleteContent
    + CategoryInfo          : InvalidOperation: (540:Int32) [Export-Mailbox],
   RecipientTaskException
    + FullyQualifiedErrorId : E05CA502,Microsoft.Exchange.Management.Recipient
   Tasks.ExportMailbox
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Amit

In 2007 that was the limitation, which is removed in 2010 or above. You need to provide target mailbox. You can create or use test mailbox as target mailbox. Later, you can clean up target mailbox.
Gospodin Rasputin

ASKER
What should the name of the target mailbox be? What format? The usernames format? Not exactly sure how mailbox is names in Exchange 2007...will try the username format and see.
Thank you
Will Szymkowski

It is not a requirement for a mailbox. You can use just use a PST file instead, as I have illustrated in my first post.

Will.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Amit

As Will said, use PST. Either mailbox or PST you need to export it somewhere in 2007.
Gospodin Rasputin

ASKER
Tried to specify target mailbox and it is telling me the source and target are the same.

I thought the cmd searches for any messages marching the criteria and deletes it. Does it search in the target mailbox only!!
My Command is : Get-Mailbox -ResultSize Unlimited | Export-Mailbox -ContentKeywords "REC_2999.wmv" -TargetMailbox TEST -TargetFolder 'DeleteMsg' -DeleteContent

The new error message is:
Export-Mailbox : The source mailbox 'Test' and target mailbox 'Test' are the same, and is not supported by this command.
At line:1 char:51
+ Get-Mailbox -ResultSize Unlimited | Export-Mailbox <<<<  -ContentKeywords "RE
C_0002.wmv" -TargetMailbox Test -TargetFolder 'DeleteMsg' -DeleteContent
    + CategoryInfo          : InvalidArgument: (155:Int32) [Export-Mailbox], R
   ecipientTaskException
    + FullyQualifiedErrorId : B7EE2B39,Microsoft.Exchange.Management.Recipient
   Tasks.ExportMailbox
Will Szymkowski

Just use a the -PSTFolderPath switch. You cannot use the same mailbox as the Target mailbox.

Will.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Gospodin Rasputin

ASKER
OK Will. I'll try that and let you know.
Thanks for your help.
Murali Reddy

Because it searching the Test mailbox too, when you have not specified in the filter, just exempt it.

Makwe sure you aslways specify a date range, otherwise the command deletes any old messages matching the subjected criteria.

Something like..

Get-Mailbox -ResultSize Unlimited |Where-Object {!($_.Alias -eq "Test")} |Export-Mailbox -ContentKeywords "REC_2999.wmv" -StartDate "15/06/2010" -EndDate "18/06/2010" -TargetMailbox TEST -TargetFolder 'DeleteMsg' -DeleteContent
Amit

I assume you got the answer already. You need to exclude this mailbox.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Gospodin Rasputin

ASKER
Hi Will,
Please can you expand your command for me. I am trying to search all the inbox in my information store for a mesage titled "REC_2999.wmv" and delete them all.

In your command, is -PSTFolderPath "C:\pstfiles\filename.pst" the source where you are deleting from or the destination (target folder where you are deleting to?

I just looked at your command and it confused me now, maybe

Thank you
Gospodin Rasputin

ASKER
Hi Will/ Amit,
When I use the -PSTFolderPath switch, it complains about me using a 64bit system and the command being for 32bit system with outlook 2003 installed in it.

Any other suggestions?
Thank you
Will Szymkowski

In Exchange 2007 this is another limitation as you will need to use a 32bit workstation to export the items to a PST file. Use a 32bit client machine.

Will.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Gospodin Rasputin

ASKER
And on a 32bit client machine, how do I run the Exchange shell?
I was running these commands on the Exchange 2007n Server.
Thank you
Will Szymkowski

You need to install the 32bit Management Tools for Exchange 2007.  Once you have that installed you will be able to export to PST with no issues.

Will.
Gospodin Rasputin

ASKER
Where do i install this tool? On the exchange Server or ona workstation.
Thank you
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Will Szymkowski

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Gospodin Rasputin

ASKER
Hi Will,
I shall try this and let you know.
Thanks