65.9K
CodeProject is changing. Read more.
Home

Exchange Server Disclaimer Efficiency, Reduce email size & increase Server Capacity

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Nov 20, 2009

CPOL
viewsIcon

8900

 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 t

 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
     if InStr(1, Msg.HTMLBody, HTMLDisclaimer, vbTextCompare)
         > 0 Then // ** Check if there is one for HTML Message ** 
      '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
   End if //** added **    End If

   If Msg.TextBody <> "" Then
    if InStr(1, Msg.TextBody, TextDisclaimer, vbTextCompare)
        > 0 Then // ** Check if there is one for Text Message **       Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
End if
    //** added ** 
   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.