Monitoring event sink # 17 - Sample for adding disclaimer for outoging SMTP messages - VBScript

    1:  <SCRIPT LANGUAGE="VBScript">
    2:  Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
    3:    TextDisclaimer = vbCrLf & "DISCLAIMER:" & vbCrLf & "Sample Disclaimer added in a VBScript."
    4:     HTMLDisclaimer = "<p></p><p>DISCLAIMER:<br>Sample Disclaimer added in a VBScript."
    5:   
    6:     If Msg.HTMLBody <> "" Then
    7:        'Search for the "</body>" tag and insert our disclaimer before that tag.
    8:         pos = InStr(1, Msg.HTMLBody, "</body>", vbTextCompare)
    9:         szPartI = Left(Msg.HTMLBody, pos - 1)
   10:         szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) - (pos - 1))
   11:         Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII
   12:     End If
   13:   
   14:     If Msg.TextBody <> "" Then
   15:        Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
   16:     End If
   17:   
   18:     'Commit the content changes to the transport ADO Stream object.
   19:     Msg.DataSource.Save ' Commit the changes into the transport Stream
   20:     EventStatus = cdoRunNextSink
   21:  End Sub
   22:  </SCRIPT>