Mail queue and file locking

M

MadDogMcGee

Hi there, here's what I'm trying to do:

I'm on a Windows NT system, and want to monitor the Exchange mail queue for
new files. When there's a new file (an email) with certain keywords (i.e.
characteristic spam strings) I want to move the file to another folder so it
doesn't get sent.

Here's my approach, which is working but could probably be improved:

1. Poll the folder (waiting 1 second between polls)
2. If a file is "there", i.e. it has finished being copied across, and it is
less than 1 megabyte, scan it for keywords.
3. If the file has any keywords, move it to a different folder.
4. Goto 1.

To check if the file is copied across, I try to rename the file to itself.
If it's locked, Perl's rename function returns a 0 and if it's unlocked,
rename returns a 1.

I'm worried that using this approach of renaming files will lock them, and
prevent email from being moved out of the queue folder to be sent.

1. Is there a better way to detect new files than to poll the directory
every second?
2. What's the best way to check if a file is unlocked (i.e. fully copied
across)?
3. (Off topic) Any potential problems in scanning the NT Exchange 5.5 mail
queue folder and moving files out?


Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top