Exch2k event sink, Python under WSH
Keith Farmer
kfarmer at thuban.org
Wed Nov 13 01:00:48 EST 2002
I know I'm not the first one to try, but if anybody's managed to do
it, they've been rather quiet about it..
I've got the following saved as a wsh file:
<script language="python">
def ISMTPOnArrival_OnArrival(msg, status):
fout = open("c:\documents and
settings\administrator.thuban\desktop\test.txt", "w")
fout.write("This is a test\n")
fout.close()
status = 0
</script>
I've used the following to register it:
C:\Documents and Settings\Administrator.THUBAN\Desktop>cscript
smtpreg.vbs /setprop 1 onarrival SMTPOnArrival Sink ScriptName
"C:\Documents and Settings\Administrator.THUBAN\Desktop\ex2k_event_sink.wsh"
C:\Documents and Settings\Administrator.THUBAN\Desktop>cscript
smtpreg.vbs /add 1 onarrival SMTPOnArrival CDO.SS_SMTPOnArrivalSink
"rcpt to=*"
Despite various manipulations of the script, I get no effect. I've
attempted the same with the following vbs script which also didn't
work:
<script language="vbscript">
Private Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
Dim fs As New Scripting.FileSystemObject
Dim file As Scripting.TextStream
Set file = fs.OpenTextFile("c:\documents and
settings\administrator.thuban\desktop\test-vb.txt", ForAppending, True
)
file.Write "From: " & Msg.From & "\n"
file.Write "To: " & Msg.To & "\n"
file.Write "Subject: " & Msg.Subject & "\n"& "\n"
file.Write Msg.TextBody & "\n"& "\n"
file.Close
EventStatus = 0
End Sub
</script>
Suggestions?
More information about the Python-list
mailing list