Create Event Sink to redirect email exchange 2003

BrendanKing
BrendanKing used Ask the Experts™
on
Hi Guys

Please note I have never done an event sink before.

Trying to create an event sink that will copy incoming emial from one domain and send it to a second email address

I have copied smtpreg.vbs to the server.
and run scripts
cscript smtpreg.vbs /add 1 onarrival SMTPScriptingHost CDO.SS_SMTPOnArrivalSink "MAIL FROM=*@kingcomputer.com.au"

and

cscript smtpreg.vbs /setprop 1 onarrival SMTPScriptingHost Sink ScriptName "C:\EventSink\Redirect_ES.vbs"

This looks to complete successfully so I assume the issue is with my event sink script.
See attached code.
<SCRIPT LANGUAGE="VBScript">
Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
Dim ForwardRcpt_str

ForwardRcpt_str="LGranger@Domain.com.au"

   If Msg.from="craig@domain.com.au" Then
	Msg.To=ForwardRcpt_str
   End If

    Msg.DataSource.Save

   EventStatus = cdoRunNextSink
End Sub
</SCRIPT>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Managed to get it working.

Here is how to create an event sink that will copy email inbound from one user and send to a second user.
The below scripts will redirect all emails from Craig@domain02.com and send them to the original receipt and lgranger@domain01.com

1.      You must get a copy of smtpreg.vbs
•      http://msdn.microsoft.com/en-us/library/ms528023
•      Save to c:\EventSink

2.      Create and save the Script file to c:\eventSink
•      <script language="VBScript">

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus )
on error resume next
Dim RecpList
RecpList = LCase(Msg.EnvelopeFields("http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"))
RecpList = RecpList  & "SMTP:lgranger@domain01.com;"
' address to send to

Msg.EnvelopeFields("http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist") = RecpList
Msg.EnvelopeFields.update

End Sub
</script>
3.      Run the below command
•      cscript smtpreg.vbs /add 1 onarrival MailRedirect CDO.SS_SMTPOnArrivalSink "mail from=craig@domain02.com"
•      MailRedirect is Name of Sink
•      CDO.SS_SMTPOnArrivalSink type of Sink
•      "mail from=craig@kingcomputer.com.au" is rule, What emails are to have the script run against.
•      this could also be Rcpt to=*@domain.com
4.      Run the below Command
•      Cscript smtpreg.vbs /setprop 1 onarrival MailRedirect Sink ScriptName C:\EventSink\Redirect_ES01.vbs
•      Note MailRedirect must equal name of Sink (Onarrival MailRedirect)
5.      Restart Exchange SMTP Service


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial