Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Sometime we need to trap all the outgoing/incoming email messages and would like to forward a copy of it to another recipient mailbox.
Here is sample script to achieve that:
Step 1: Install Exchange 2003 SDK on your Exchange Server. You can download it at the following link.
https://www.microsoft.com/downloads/details.aspx?FamilyID=a865936f-50da-47a0-9dce-f24e8307f38d&DisplayLang=en
Step 2: Open Notepad and Paste the following code to it and save it as forward.vbs
NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures.
1: <SCRIPT LANGUAGE="VBScript">
2:
3: Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
4:
5: Dim RecpList
6:
7: recplist = Msg.EnvelopeFields("https://schemas.microsoft.com/cdo/smtpenvelope/recipientlist")
8:
9: 'Change "administrator@dc.com" to the mailbox address to which you want to send a B’cc copy
10: If ( Instr(recplist,"SMTP:administrator@dc.com;") =< 0) then
11: recplist = recplist & "SMTP:administrator@dc.com;"
12: End If
13: Msg.EnvelopeFields("https://schemas.microsoft.com/cdo/smtpenvelope/recipientlist") = recplist
14: Msg.EnvelopeFields.update
15: WriteLog(Msg.EnvelopeFields("https://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"))
16: WriteLog("Done")
17: End Sub
18:
19: Sub WriteLog(ByVal strMessage)
20: Dim fs
21: Set fs = CreateObject("Scripting.FileSystemObject")
22: Dim file
23:
24: 'change "C:\bnewlog.txt" name/path of the log file
25: Set file = fs.opentextfile("C:\bnewlog.txt", 8, True)
26: file.Write strMessage
27: file.Close
28: End Sub
29:
30: </SCRIPT>
Step 3: Register the event sink
========================
1. Click Start -> Run, Type "cmd" and Click OK
2. Type "CD C:\Program Files\Exchange SDK\SDK\Support\CDO\Scripts" and Press Enter
3. Type cscript smtpreg.vbs /add 1 onarrival SMTPScriptingHost CDO.SS_SMTPOnArrivalSink "mail from=*" and Press Enter
4. Type cscript smtpreg.vbs /setprop 1 onarrival SMTPScriptingHost Sink ScriptName "C:\forward.vbs" and Press Enter (make sure that the path to forward.vbs is correct)
Now, all the incoming/outgoing emails bcc'ed/copied to administrator@dc.com.
To unregister this event, type the following:
cscript smtpreg.vbs /remove 1 OnArrival SMTPScriptingHost
Please also refer to the following article 273233:You cannot modify MAPI messages that are trapped in an SMTP transport event sink.
Feel free to post your comments or request for messaging related development issues.
Comments
- Anonymous
November 03, 2008
PingBack from http://mstechnews.info/2008/11/how-to-send-a-copy-of-all-smtp-mails-to-another-recipient-mailbox-using-smtp-event-sink/