CommandLine parameters to delete messages from mailbox

Discussions on webmail and the Professional version.
Post Reply
labsy
Posts: 148
Joined: Sun Nov 16, 2003 6:49 am
Location: Slovenia

CommandLine parameters to delete messages from mailbox

Post by labsy »

Is there any CommandLine option to delete all messages from some specific mailbox? I need it to execute via BATCH file.

paarlberg
Posts: 1071
Joined: Tue Mar 02, 2004 7:33 pm
Location: Atlanta, GA, USA

Post by paarlberg »

I use this to clear out deleted items on a regular basis.

You would just need to change the 4th line and replace "Deleted Items" to the root of the user mailbox like below

"c:\progra~1\mailenable\postoffices\poname\mailbox\username\"

I run this at the root of the postoffices folder so it look thru all po and users.

Code: Select all

@echo off
cls
setlocal
Dir "Deleted Items" /S /B /O:-D /T:C > 2dellist.txt
For /f "delims=/" %%a in (2dellist.txt)do del "%%a\*.mai" /f /q
Endlocal
Exit

labsy
Posts: 148
Joined: Sun Nov 16, 2003 6:49 am
Location: Slovenia

Post by labsy »

Nice, thanx!

btw - does this delete message envelopes too, or just messages?

paarlberg
Posts: 1071
Joined: Tue Mar 02, 2004 7:33 pm
Location: Atlanta, GA, USA

Post by paarlberg »

If it is in the mailbox already, you only have the message file.

scngan
Posts: 446
Joined: Fri Dec 30, 2005 1:27 pm

Post by scngan »

paarlberg wrote:I use this to clear out deleted items on a regular basis.

You would just need to change the 4th line and replace "Deleted Items" to the root of the user mailbox like below

"c:\progra~1\mailenable\postoffices\poname\mailbox\username"

I run this at the root of the postoffices folder so it look thru all po and users.

Code: Select all

@echo off
cls
setlocal
Dir "Deleted Items" /S /B /O:-D /T:C > 2dellist.txt
For /f "delims=/" %%a in (2dellist.txt)do del "%%a\*.mai" /f /q
Endlocal
Exit
hi there,
you means u put at:
c:\program files\mailenable\postoffice ?
in order for me to let the batch delete all the deleted item folder in my whole server postoffice ?
so when i execute, it will auto get all "deleted item" folder message and delete it if i 100% copy your above code and paste on my server ?

paarlberg
Posts: 1071
Joined: Tue Mar 02, 2004 7:33 pm
Location: Atlanta, GA, USA

Post by paarlberg »

If you want to test the script, place it in
C:\Program Files\Mail Enable\Postoffices\

and use the version below.. notice that line 5 from the original script is missing.

Code: Select all

@echo off 
cls 
setlocal 
Dir "Deleted Items" /S /B /O:-D /T:C > 2dellist.txt 
Endlocal 
Exit 
This will create a file called 2dellist.txt which will show all "deleted items" folders in all mailboxes. It will not delete anything..

If you run the original script I posted, then it will read the values in the 2dellist.txt file and delete any file with the .mai extension in those folders.

labsy
Posts: 148
Joined: Sun Nov 16, 2003 6:49 am
Location: Slovenia

Post by labsy »

As I run the script, I had to remove *.MAI from the 5th line in order to run properly. Otherways, I got "Path not found" error:

Original line (BOLD is problematic):
For /f "delims=/" %%a in (2dellist.txt)do del "%%a\*.mai" /f /q

Modified line:
For /f "delims=/" %%a in (2dellist.txt)do del "%%a" /f /q

paarlberg
Posts: 1071
Joined: Tue Mar 02, 2004 7:33 pm
Location: Atlanta, GA, USA

Post by paarlberg »

If it says path not found, then there were no files matching *.mai in the folders. That is normal. Also if you don't specify a file type either by *.mai or *.* it won't delete anything.

Post Reply