I did this in IMail last year and it's still working great.  I created a
program alias called spamhold under the clients account and redirected all
failed messages to this address.  The program alias calls a VB.NET console
application I wrote that creates a "spamhold" folder under clients folder.
It subsequently creates a new folder for each month and stores all the spam
as eml text files.  Only problem with it is that I have some customers that
get massive amounts of spam and the data slows down my nightly backups.

Here's the main part of my code:

    Sub Main()

        'The 2 event handlers 
        'add an unhandled exceptions handler 
        Dim currentDomain As AppDomain = AppDomain.CurrentDomain
        'for regular unhandled stuff 
        AddHandler currentDomain.UnhandledException, AddressOf
MYExceptionHandler

        Dim spamname As String = String.Empty

        'make sure spam folder exists
        Dim spamfolder As New IO.DirectoryInfo(Current & "\spamhold")
        If spamfolder.Exists = False Then spamfolder.Create()

        'build string for current year and month
        Dim nMonth As Integer = Today.Month
        Dim cMonth As String
        If nMonth < 10 Then
            cMonth = "0" & nMonth.ToString
        Else
            cMonth = nMonth.ToString
        End If
        Dim cYearMonth As String = Today.Year.ToString & "-" & cMonth

        'make sure folder exists for current month
        Dim monthfolder As New IO.DirectoryInfo(Current & "\spamhold\" &
cYearMonth)
        If monthfolder.Exists = False Then monthfolder.Create()

        'open the log file
        Dim spamlog As New StreamWriter(Current & "\spamhold.log", True)

        Try
            'if a file name was passed in, move the file from source into
spam folder
            If Args.Length > 1 Then
                spamfile = New IO.FileInfo(Args(1))
                If spamfile.Exists Then

                    'loop until an unused file name is found
                    Do While True
                        Randomize()
                        spamname = "spam" & cYearMonth & "-" &
Today.Day.ToString & "-" & Fix(Rnd(9999999) * 10000000) & Second(Now) &
".eml"
                        targetfile = New IO.FileInfo(Current & "\spamhold\"
& cYearMonth & "\" & spamname)
                        If targetfile.Exists = False Then
                            spamfile.MoveTo(Current & "\spamhold\" &
cYearMonth & "\" & spamname)
                            spamlog.WriteLine(DateTime.Now & ": " &
spamname)
                            Exit Do
                        End If
                    Loop

                End If
            End If

        Catch ex As Exception
            spamlog.WriteLine(DateTime.Now & ": ERROR" & spamname)
        End Try
        spamlog.Close()
    End Sub


-Gary

Gary Jorgenson, RN President/CEO - Robin Technologies, Inc.
670 Lakeview Plaza Blvd., Suites I & J | Worthington, OH 43085
Phone: 614.888.3001 | Fax: 614.888.3002 | Cell: 614.961.0670
[EMAIL PROTECTED] | www.robintek.com 


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Travis Rabe
Sent: Tuesday, November 11, 2008 2:32 PM
To: Imail_Forum@list.ipswitch.com
Subject: RE: [IMail Forum] Anyone have a tool that can do this.

I do this with my barracuda spam firewall.  I tried a while back to do this
with Imail natively and it was a mess.  My .02

TR



To Unsubscribe: http://imailserver.com/support/discussion_list/
List Archive: http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
Knowledge Base/FAQ: http://imailserver.com/support/kb.html

Reply via email to