i have server 2000 with iis
code is here:
<SCRIPT RunAt=Server Language=VBScript>
' FILE DESCRIPTION: Saves all attachments of a new arrived message to a
' particular directory
'
Option Explicit
'------------------------------------------------------------------------------
' Global Variables
'------------------------------------------------------------------------------
Dim g_bstrDebug ' Debug String
'------------------------------------------------------------------------------
' CONSTANTS
'------------------------------------------------------------------------------
Dim g_Const_MBX
Dim g_Const_Directory
' Enter the display name of the mailbox which you want have send the report to
g_Const_MBX = "Jaanus Jekimov"
' Enter the directory where you want to save all attachments
g_Const_Directory = "c:\"
'------------------------------------------------------------------------------
' EVENT HANDLERS
'------------------------------------------------------------------------------
' DESCRIPTION: This event is fired when a new message is added to the folder
Public Sub Folder_OnMessageCreated
Dim objSession ' Session
Dim objCurrentMsg ' Current message
Dim objFolder ' Current folder
Dim objAttachment ' Attachment object
Dim objAttachments ' Attachment collection
' Initialize objects
Set objSession = Nothing
Set objCurrentMsg = Nothing
Set objFolder = Nothing
Set objAttachment = Nothing
Set objAttachments = Nothing
' Clear error buffer
Err.Clear
' Get session informationen
Set objSession = EventDetails.Session
' No errors detected ?
If Err.Number = 0 Then
' Write some logging
Call DebugAppend(objSession.CurrentUser & " SendAtt - Proccessing startet", False)
' Get current folder
Set objFolder = objSession.GetFolder(EventDetails.FolderID,Null)
' No errors detected ?
If Err.Number = 0 Then
' Get current message
Set objCurrentMsg = objSession.GetMessage(EventDetails.MessageID,Null)
' Error detected ?
If Not Err.Number = 0 Then
' Error reading new message
Call DebugAppend("Error - Could not read message", True)
Else
' Set current message to read
objCurrentMsg.Unread = False
' Remember subject of arrived message
Call DebugAppend("New message with subject: <" & objCurrentMsg.Subject & "> arrived", False)
' Get attachment of the message
On Error Resume Next
Set objAttachments = objCurrentMsg.Attachments
' No errors detected?
If Not objAttachments Is Nothing Then
' Attachments found, write logging
Call DebugAppend("Attachments found", False)
' Extract all attachments
For Each objAttachment In objAttachments
' Check if attachment is a file or link
' Note that CDO 1.2x does not support to save OLE objects
' and embedded messages to the file system
If (objAttachment.Type = 1) Or (objAttachment.Type = 2) Then
' Save attachment to the filesystem, write logging
Call DebugAppend("Save attachments to filesystem", False)
' Write attachment to the filesystem
objAttachment.WriteToFile(g_Const_Directory & objAttachment.Name)
End If
Next
' Delete attachments
On Error Resume Next
objAttachments.Delete
End If
' Update message
On Error Resume Next
objCurrentMsg.Update
' Error detected ?
If Err.Number <> 0 then
' Could not sent message, write logging
Call DebugAppend("Error - Could not update message", True)
Else
' Message successfully sent
Call DebugAppend("Success - Message updated successfully", False)
End If
End If
Else
' Could not get current folder
Call DebugAppend("Error - Could not get current folder", True)
End If
Else
' Check for any possible sys errors
Call DebugAppend("Undefinied Error detected", True)
End If
' Write some logging, without the folder name
Call DebugAppend("SaveAtt - Processing finished", False)
' Clear objects
Set objSession = Nothing
Set objCurrentMsg = Nothing
Set objFolder = Nothing
Set objAttachment = Nothing
Set objAttachments = Nothing
' Write results to the Scripting Agent log
Script.Response = g_bstrDebug
End Sub
' DESCRIPTION: This event is fired when the timer on the folder expires
Public Sub Folder_OnTimer
'Not used
End Sub
' DESCRIPTION: This event is fired when a message in the folder is changed
Public Sub Message_OnChange
'Not used
End Sub
' DESCRIPTION: This event is fired when a message is deleted from the folder
Public Sub Folder_OnMessageDeleted
'Not used
End Sub
'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
' PRIVATE FUNCTIONS/SUBS
'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
'------------------------------------------------------------------------------
' Name: DebugAppend
' Area: Debug
' Desc: Simple Debugging Function
' Parm: String Text, Bool ErrorFlag
'------------------------------------------------------------------------------
Private Sub DebugAppend(bstrParm,boolErrChkFlag)
If boolErrChkFlag = True Then
If Err.Number <> 0 Then
g_bstrDebug = g_bstrDebug & bstrParm & " - " & cstr(Err.Number) & " " & Err.Description & vbCrLf
Err.Clear
End If
Else
g_bstrDebug = g_bstrDebug & bstrParm & vbCrLf
End If
End Sub
</SCRIPT>