WScript.Shell with Exchange Store Event Sink using VBScript

WScript.Shell with Exchange Store Event Sink using VBScript

Post by mrbrown_19 » Fri, 14 Nov 2003 20:47:52


I have implemented an Exchange Store Event Sink (Exch 2k SP3) in
VBScript using the following code:

<script language="vbscript">
Dim sLogPath
sLogPath = "c:\event.txt"

Sub ExStoreEvents_OnSave(ptrEventInfo, bstrURLItem, lFlags)
set WshShell = CreateObject("WScript.Shell")
strrun = WshShell.run("c:\OnSave.vbs")
set WshShell = nothing

WriteToLog "WriteToLog (OnSave): " & bstrURLItem
End Sub

Sub ExStoreEvents_OnDelete(ptrEventInfo, bstrURLItem, lFlags)
WriteToLog "WriteToLog (OnDelete): " & bstrURLItem
End Sub

Sub WriteToLog(s)
Set fso = CreateObject("Scripting.FileSystemObject")
set wfile = fso.opentextfile(sLogPath,8,true)
wfile.writeline s
wfile.close
set fso = nothing
set wfile = nothing
End Sub
</script>

The file referenced in ExStoreEvents_OnSave, OnSave.vbs, is as
follows:

sLogPath = "c:\zevent.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
set wfile = fso.opentextfile(sLogPath,8,true)
wfile.writeline "OK"
wfile.close
set fso = nothing
set wfile = nothing

However, it appears that OnSave.vbs is not called by the event sink.
This is despite the fact that the WriteToLog line works OK and a line
is added to "event.vbs" for the OnSave method.

I have tried modifying the event sink code to

strrun = WshShell.run("c:\OnSave.vbs", 0, True)

but this has no effect. The method returns 0 each time.

Can anyone shed any light on why the WScript.Shell.Run method is not
working here? I have seen several examples of this implementation at
www.outlookexchange.com, but it will not work for me.

Thanks

Will
 
 
 

WScript.Shell with Exchange Store Event Sink using VBScript

Post by mrbrown_19 » Tue, 18 Nov 2003 18:50:26

I have also noticed in Task Manager that an instance of wscript.exe is
created each time the script runs, so obviously the external script
does get called. But I am still at a loss to explain why it doesn't
function properly.

Anyone?

 
 
 

WScript.Shell with Exchange Store Event Sink using VBScript

Post by mrbrown_19 » Thu, 20 Nov 2003 18:32:47

Would you believe it, it wasn't working due to a typo in the OnSave.vbs script...