none
SMTP Event Sink - Bounce Email RRS feed

  • Question

  • The following script is running on IIS Virtual SMTP server, on Windows 2003 R2 SP2:

    <SCRIPT language="VBScript">
    
    ' CdoEventStatus 
    Const cdoRunNextSink = 0			'Proceed to run the next sink.
    Const cdoSkipRemainingSinks = 1		'Skip (do not notify) any remaining sinks.
    
    ' messagestatus
    Const cdoStatSuccess = 0			'Success
    Const cdoStatAbortDelivery = 2		'Do not deliver the message.
    Const cdoStatBadMail = 3			'Do not deliver the message and place it in the bad mail location.
    
    Sub ISMTPOnArrival_OnArrival(ByVal cdoMessage, EventStatus)
     On Error Resume Next 
    
     ''
     ' Process Message
     '
     Call ProcessMessage(cdoMessage)
    
     ''
     ' Abort message delivery
     '
     cdoMessage.Fields.Item("http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus").Value = cdoStatAbortDelivery
     cdoMessage.Fields.Update
    
     eventStatus = cdoSkipRemainingSinks
      
     ''
     ' Save changes
     '
     cdoMessage.DataSource.Save
    
    End Sub
    
    Sub ProcessMessage(ByVal cdoMessage)
     ''
     ' Do Stuff
     '
     
    End Sub
    
    </SCRIPT>
    
    

     

    The mails that arrive on SMTP relay server, are processed, and then are supposed to be discarded (deleted); The script is based on "How to configure an Internet Information Services SMTP virtual server to archive or to remove messages in an Exchange Server 2003 test environment" KB Article.

    The problem is that the messages are not deleted...

    Any pointers?

     

    George J.


    MVP(VSTO), Athens, Greece
    Thursday, December 16, 2010 5:27 PM

Answers

  • You need to use the EnvelopeFields collection to set envelope fields

    eg

    	Set objFields = objMessage.EnvelopeFields
    	With objFields
    
    		' 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
    

     A good example (although very old) is http://www.cdolive.com/download/smtptransportevent-attachmentfilter.zip

    Cheers
    Glen

    Friday, December 17, 2010 2:29 AM

All replies

  • You need to use the EnvelopeFields collection to set envelope fields

    eg

    	Set objFields = objMessage.EnvelopeFields
    	With objFields
    
    		' 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
    

     A good example (although very old) is http://www.cdolive.com/download/smtptransportevent-attachmentfilter.zip

    Cheers
    Glen

    Friday, December 17, 2010 2:29 AM
  • Glen,

    Thank you for your answer - I was using the .Fields collection instead .EnvelopFields...

     

    George J.


    MVP(VSTO), Athens, Greece
    Tuesday, December 21, 2010 5:05 AM