Introduction
This articles is intended to reduce multiple disclaimer messages when we reply and forward the mail messages. As we know that the business related messages mostly replied several times and same disclaimer message automatically added by Exchange Server everytime. It increases the message size with same disclaimer everytime when replied or forwarded. But there is a easy solution to prevent that if there is already one attached.
Ofcourse this idea can be applied to any mail server which adds auto company disclaimer messages.
We will use Microsoft support Article KB 317680 to show the solution.
This will reduce mail sizes , Internet traffic and improve Exchange Server perfprmance also..
Using the Code
Simply I check the predefined disclaimer text if does not exists, add one..
I use VB Scipt sample but it can be used/applied with any language.
I show added lines in bold and red with comments.
EventSinkScript.vbs.
<SCRIPT LANGUAGE="VBScript">
Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
TextDisclaimer = vbCrLf & "DISCLAIMER:" & vbCrLf & "Sample Disclaimer added in a VBScript."
HTMLDisclaimer = "<p></p><p>DISCLAIMER:<br>Sample Disclaimer added in a VBScript."
If Msg.HTMLBody <> "" Then
<span style="COLOR: darkred">if InStr(1, Msg.HTMLBody, HTMLDisclaimer, vbTextCompare)
> 0 Then </span>
'Search for the "</body>" tag and insert our disclaimer before that tag.
pos = InStr(1, Msg.HTMLBody, "</body>", vbTextCompare)
szPartI = Left(Msg.HTMLBody, pos - 1)
szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) - (pos - 1))
Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII
<span style="COLOR: brown">End if //** added ** </span> End If
If Msg.TextBody <> "" Then
<span style="COLOR: #8b0000">if InStr(1, Msg.TextBody, TextDisclaimer, vbTextCompare)
> 0 Then // ** Check if there is one for Text Message ** </span> Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
<span style="COLOR: #a52a2a"></span><span style="COLOR: #a52a2a">End if
//** added **</span><span style="COLOR: #a52a2a"> </span>
End If
'Commit the content changes to the transport ADO Stream object.
Msg.DataSource.Save ' Commit the changes into the transport Stream
EventStatus = cdoRunNextSink
End Sub
</SCRIPT>
You can refer to Microsoft' s KB 317680 to register EventSinkScript.vbs on Exchange Server.