[python-win32] Exchange 2k Event Sink?
Keith J. Farmer
kfarmer@thuban.org
Wed, 13 Nov 2002 14:30:38 -0800
This is a multi-part message in MIME format.
------_=_NextPart_001_01C28B64.4A9B9198
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
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=3D"python">
def ISMTPOnArrival_OnArrival(msg, status):
fout =3D open("c:\documents and
settings\administrator.thuban\desktop\test.txt", "w")
fout.write("This is a test\n")
fout.close()
status =3D 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=3D*"
Despite various manipulations of the script, I get no effect. I've
attempted the same with the following vbs script from microsoft, which
should have worked, but didn't:
<script language=3D"vbscript">
Private Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
Dim fs As New Scripting.FileSystemObject
Dim file As Scripting.TextStream
Set file =3D 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 =3D 0
End Sub
</script>
Suggestions?
=20
------_=_NextPart_001_01C28B64.4A9B9198
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY dir=3Dltr bgColor=3D#ffffff>
<P>I know I'm not the first one to try, but if anybody's managed to do =
it,=20
they've been rather quiet about it..</P>
<P>I've got the following saved as a wsh file:</P>
<P><script language=3D"python"><BR>def =
ISMTPOnArrival_OnArrival(msg,=20
status):<BR> fout =3D open("c:\documents and=20
settings\administrator.thuban\desktop\test.txt", =
"w")<BR> =20
fout.write("This is a test\n")<BR> =20
fout.close()<BR> status =3D 0<BR></script></P>
<P>I've used the following to register it:</P>
<P>C:\Documents and Settings\Administrator.THUBAN\Desktop>cscript =
smtpreg.vbs=20
/setprop 1 onarrival SMTPOnArrival Sink ScriptName "C:\Documents and=20
Settings\Administrator.THUBAN\Desktop\ex2k_event_sink.wsh"</P>
<P>C:\Documents and Settings\Administrator.THUBAN\Desktop>cscript =
smtpreg.vbs=20
/add 1 onarrival SMTPOnArrival CDO.SS_SMTPOnArrivalSink "rcpt =
to=3D*"</P>
<P>Despite various manipulations of the script, I get no effect. =
I've=20
attempted the same with the following vbs script from microsoft, which =
should=20
have worked, but didn't:</P>
<P><script language=3D"vbscript"><BR>Private Sub=20
ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)<BR> =
Dim fs As=20
New Scripting.FileSystemObject<BR> Dim file As=20
Scripting.TextStream<BR> Set file =3D=20
fs.OpenTextFile("c:\documents and=20
settings\administrator.thuban\desktop\test-vb.txt", ForAppending, True=20
)<BR> file.Write "From: " & Msg.From &=20
"\n"<BR> file.Write "To: " & Msg.To &=20
"\n"<BR> file.Write "Subject: " & Msg.Subject =
&=20
"\n"& "\n"<BR> file.Write Msg.TextBody & =
"\n"&=20
"\n"<BR> file.Close<BR> EventStatus =
=3D=20
0<BR>End Sub<BR></script></P>
<P>Suggestions?</P>
<P> </P></BODY></HTML>
=00
------_=_NextPart_001_01C28B64.4A9B9198--