Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script to Delete dead messages from  C:\inetpub\mailroot\badmail

Posted on 2008-06-15
2
Medium Priority
?
2,656 Views
Last Modified: 2012-05-09
I have a mail gateway server that is accepting mail for 5 domains and i have about 1000 undeliverble messages  in the  c:\inetpub\mailroot\badmail folder perday what the best way  automatically deleting these messages
0
Comment
Question by:thombie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Assisted Solution

by:Compaq_Engineer
Compaq_Engineer earned 200 total points
ID: 21788057
Schedule a batchfile to run at a time of low server use using Windows Task Scheduler
The batchfile doesn't need to be anything complicated. I would use as below;-

C:
cd \inetpub\mailroot\badmail
del *.* /Q

Hope that helps.
0
 
LVL 58

Accepted Solution

by:
tigermatt earned 800 total points
ID: 21788138
I've attached below a VBS script which I configure as a Scheduled Task where it is necessary to go through and clear this folder out. The difference with this script is it will only delete mail which is 7 days old (although that value can easily be changed), so it gives you chance to check the Badmail queue before the messages are deleted.

You can simply select the script in the Scheduled Task box and configure it to run once a day, once an hour or at any other interval you choose. The script will then go through and delete all the mail which is more than iDaysOld - change the number assigned to the iDaysOld variable near the top if you want to delete mail which is less old, perhaps only 3 days old.

-tigermatt
Dim oFSO
Dim oFolder
Dim oFile
Dim iDaysOld
 
'Customize values here to fit your needs
      iDaysOld=7
      Set oFSO=CreateObject("Scripting.FileSystemObject")
      set oFolder=oFSO.GetFolder("C:\inetpub\mailroot\badmail")
 
'Walk through each file in this folder collection. 
'If it is older than iDaysOld days, then delete it.
 
For each oFile in oFolder.Files
If oFile.DateLastModified < (Date() - iDaysOld) Then                               
oFSO.DeleteFile oFolder.Path & "\" & oFile.Name
End If
Next
 
'Clean up
      Set oFSO = Nothing
      Set oFolder = Nothing
      Set oFileCollection = Nothing
      Set oFile = Nothing

Open in new window

0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question