[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>&lt;script language=3D"python"&gt;<BR>def =
ISMTPOnArrival_OnArrival(msg,=20
status):<BR>&nbsp;&nbsp;&nbsp; fout =3D open("c:\documents and=20
settings\administrator.thuban\desktop\test.txt", =
"w")<BR>&nbsp;&nbsp;&nbsp;=20
fout.write("This is a test\n")<BR>&nbsp;&nbsp;&nbsp;=20
fout.close()<BR>&nbsp;&nbsp;&nbsp; status =3D 0<BR>&lt;/script&gt;</P>
<P>I've used the following to register it:</P>
<P>C:\Documents and Settings\Administrator.THUBAN\Desktop&gt;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&gt;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.&nbsp; =
I've=20
attempted the same with the following vbs script from microsoft, which =
should=20
have worked, but didn't:</P>
<P>&lt;script language=3D"vbscript"&gt;<BR>Private Sub=20
ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)<BR>&nbsp;&nbsp;&nbsp; =
Dim fs As=20
New Scripting.FileSystemObject<BR>&nbsp;&nbsp;&nbsp; Dim file As=20
Scripting.TextStream<BR>&nbsp;&nbsp;&nbsp; Set file =3D=20
fs.OpenTextFile("c:\documents and=20
settings\administrator.thuban\desktop\test-vb.txt", ForAppending, True=20
)<BR>&nbsp;&nbsp;&nbsp; file.Write "From: " &amp; Msg.From &amp;=20
"\n"<BR>&nbsp;&nbsp; &nbsp;file.Write "To: " &amp; Msg.To &amp;=20
"\n"<BR>&nbsp;&nbsp;&nbsp; file.Write "Subject: " &amp; Msg.Subject =
&amp;=20
"\n"&amp; "\n"<BR>&nbsp;&nbsp;&nbsp; file.Write Msg.TextBody &amp; =
"\n"&amp;=20
"\n"<BR>&nbsp;&nbsp;&nbsp; file.Close<BR>&nbsp;&nbsp;&nbsp; EventStatus =
=3D=20
0<BR>End Sub<BR>&lt;/script&gt;</P>
<P>Suggestions?</P>
<P>&nbsp;</P></BODY></HTML>
=00
------_=_NextPart_001_01C28B64.4A9B9198--