RE: Event Sinks to search Body
- From: "John Tolmachoff \(Lists\)" <johnlist@xxxxxxxxxxxxxxxxxxx>
- To: "'[ExchangeList]'" <exchangelist@xxxxxxxxxxxxx>
- Date: Thu, 30 Oct 2003 13:14:37 -0800
Attached is the vbs script.
The desired outcome is to search the body for certain keywords, (not spam or
such, but a business requirement) and redirect to a different recipient.
John Tolmachoff
Engineer/Consultant/Owner
eServices For You
john@xxxxxxxxxxxxxxxxxxx
626-737-6003
Fax 626-737-6004
www.eservicesforyou.com <http://www.eservicesforyou.com/>
-----Original Message-----
From: Mulnick, Al [mailto:Al.Mulnick@xxxxxxxxxx]
Sent: Thursday, October 30, 2003 9:15 AM
To: [ExchangeList]
Subject: [exchangelist] RE: Event Sinks to search Body
http://www.MSExchange.org/
There should be more to it than that. Can you post the code?
_____
From: John Tolmachoff (Lists) [mailto:johnlist@xxxxxxxxxxxxxxxxxxx]
Sent: Thursday, October 30, 2003 12:00 AM
To: [ExchangeList]
Subject: [exchangelist] Event Sinks to search Body
http://www.MSExchange.org/
I am not a program and know about 10 commands for scripting.
I have a client that would like to check incoming messages and redirect.
I have a sample script from Siegfried Weber that some one was kind enough to
send to me a few months ago and have some questions.
There is one event script he has to search the subject and take action. I
need to look at the body.
Can I just change all references of subject to body, such as strSubject
becomes strBody and CATCH_SUBJECT becomes CATCH_BODY, or is there more to it
than that? This is in a vb script.
John Tolmachoff
Engineer/Consultant/Owner
eServices For You
------------------------------------------------------
List Archives: http://www.webelists.com/cgi/lyris.pl?enter=exchangelist
Exchange Newsletters: http://www.msexchange.org/pages/newsletter.asp
Exchange FAQ: http://www.msexchange.org/pages/larticle.asp?type=FAQ
------------------------------------------------------
Other Internet Software Marketing Sites:
Leading Network Software Directory: http://www.serverfiles.com
No.1 ISA Server Resource Site: http://www.isaserver.org
Windows Security Resource Site: http://www.windowsecurity.com/
Network Security Library: http://www.secinf.net/
Windows 2000/NT Fax Solutions: http://www.ntfaxfaq.com
------------------------------------------------------
------------------------------------------------------
List Archives: http://www.webelists.com/cgi/lyris.pl?enter=exchangelist
Exchange Newsletters: http://www.msexchange.org/pages/newsletter.asp
Exchange FAQ: http://www.msexchange.org/pages/larticle.asp?type=FAQ
------------------------------------------------------
Other Internet Software Marketing Sites:
Leading Network Software Directory: http://www.serverfiles.com
No.1 ISA Server Resource Site: http://www.isaserver.org
Windows Security Resource Site: http://www.windowsecurity.com/
Network Security Library: http://www.secinf.net/
Windows 2000/NT Fax Solutions: http://www.ntfaxfaq.com
------------------------------------------------------
<SCRIPT LANGUAGE="VBSCRIPT">
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
' PURPOSE
'
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in any other format.
'
'------------------------------------------------------------------------------
'
' NAME: SubjectFilter.vbs
' VERSION: 2.0 - 5/20/2003
'
' DESCRIPTION: Deletes a message from the Windows 2000/2003 SMTP service
' if the subject matches "PORN"
'
' Copyright (c) CDOLive LLC 1998-2003, Siegfried Weber. All rights reserved.
' http://www.cdolive.net/samples/?item=SubjectFilter
' mailto:samples@xxxxxxxxxxx?subject=SubjectFilter
'
'------------------------------------------------------------------------------
' Declare Windows 2000/2003 SMTP Transport Event Sink constants
Const cdoRunNextSink = 0
Const cdoSkipRemainingSinks = 1
Const cdoStatAbortDelivery = 2
Const cdoStatBadMail = 3
' Set to false if you do not want to keep any messages in the Windows SMTP
BADMAIL folder
Const ENABLE_BADMAIL = True
' Subject to catch
Const CATCH_SUBJECT = "PORN"
Sub ISMTPOnArrival_OnArrival(ByVal objMessage, EventStatus)
' Initialize error checking
On Error Resume Next
' Declare variables
Dim strSubject ' As String
Dim objFields ' As ADODB.Fields
' Get fields collection of message
Set objFields = objMessage.EnvelopeFields
With objFields
' Check subject
strSubject = objMessage.Subject
If strSubject = CATCH_SUBJECT Then
' Check if message should be saved
If ENABLE_BADMAIL = True Then
.Item("http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus").Value =
cdoStatBadMail
Else
.Item("http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus").Value =
cdoStatAbortDelivery
End If
.Update
EventStatus = cdoSkipRemainingSinks
Else
' No match found, continue with next sink
EventStatus = cdoRunNextSink
End If
End With
' Tidy up
Set objFields = Nothing
End Sub
</SCRIPT>
Other related posts: