Sorry, I've been away from email for several days. (Good for me!)

Anyway, you need to be using the namespaces. See below. You also need to
be aware that the format of the recipient list is
"SMTP:[EMAIL PROTECTED];SMTP:[EMAIL PROTECTED];SMTP:[EMAIL PROTECTED]" so it 
requires a bit of
parsing. Otherwise, your plan isn't bad. As Chris pointed out, a
protocol sink is probably a better solution, but it's much more
difficult to write.

'
' For information about this namespace, see 
'
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/
html/_cdosys_schema_smtpenvelope.asp
'
Const RECIP_LIST =
"http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist";
'
' For information about the CdoEventStatus enumeration, see 
'
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/
html/_cdosys_cdoeventstatus_enum.asp
'
Const CDO_RUN_NEXT_SINK = 0
'
Sub ISMTPOnArrival_OnArrival (ByVal Msg, EventStatus)
        Dim objFields
        Dim strInput
        Dim strOutput

        On Error Resume Next

        If DoSetup () Then
                Set objFields = Msg.EnvelopeFields
                strInput = objFields (RECIP_LIST).Value

                If bDebug Then
                        objShell.LogEvent EVENT_SUCCESS, "Event sink
input: '" & strInput & "'"
                End If

                If Len (strInput) > 0 Then
                        strOutput = FixupRecipientList (strInput)

                        objFields (RECIP_LIST).Value = strOutput
                        objFields.Update
  
                        Msg.DataSource.Save ' Commit changes
                End If

                If bDebug Then
                        objShell.LogEvent EVENT_SUCCESS, "Event sink
output: '" & strOutput & "' time = " & (Timer - StartTime)
                End If

                Call DoCleanup ()
        End If

        EventStatus = CDO_RUN_NEXT_SINK

End Sub 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Evan
Mann
Sent: Tuesday, November 22, 2005 6:55 PM
To: Exchange Discussions
Subject: SMTP Event Sink help

Anyone good with SMTP Event Sinks?  Here's what I'm trying to
accomplish:

If e-mail is sent TO [EMAIL PROTECTED] OR [EMAIL PROTECTED] and it's
NOT from [EMAIL PROTECTED] then dump the mail.

Ideally, dump the mail means reject it and send the user an
undeliverable response of some kind.  But in reality, it could be as
simple as send the mail to badmail.

I came up with this script, but am looking for some validation on if I'm
using the correct msg variables and if it's the proper way to do this.
This dumps to badmail, because I really don't know how to do anything
else. I hacked up a sample script off MS's site as it is

<SCRIPT LANGUAGE="VBScript">

Sub IEventIsCacheable_IsCacheable()
        'To implement the interface, and return S_OK implicitly
End Sub

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
        Dim envFlds
        Set envFlds = Msg.EnvelopeFields

        'Check to see if the e-mail send to the mailbox has efax.com in
the senders domain
      If ((Msg.To = "[EMAIL PROTECTED]") or (Msg.To =
"[EMAIL PROTECTED]")) 
        and InStr(1, Msg.From, "sender.com") = 0 Then
                'Do not deliver, place message in the Badmail directory.
                envFlds
("http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus";) = 3
                envFlds.Update  'Commit the changes of the message
status 'Skip remain event sinks
                EventStatus = 1
        End If
End Sub

</SCRIPT>

_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Web Interface: http://intm-dl.sparklist.com/read/?forum=exchange
To subscribe: http://e-newsletters.internet.com/discussionlists.html/
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.


_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Web Interface: http://intm-dl.sparklist.com/read/?forum=exchange
To subscribe: http://e-newsletters.internet.com/discussionlists.html/
To unsubscribe send a blank email to [EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to