• Home
  • Producten
  • Bedrijfsbehoeften
  • Events
  • Partners
  • Domeinregistratie
  • Referenties
  • Kenniscentrum
  • Support
  • FAQ
  • Nieuws
  • Acties

Zoek in het kenniscentrum

0 producten: € 0,00

How to add a disclaimer to outgoing SMTP messages in Visual Basic

Gepost op 12-06-2007 - KB: E-mail - 0 reacties


De informatie in dit artikel is van toepassing op:

  • Microsoft Exchange Server 2003 Standard Edition
  • Microsoft Exchange Server 2003 Enterprise Edition
  • Microsoft Exchange 2000 Server Standard Edition
  • Collaboration Data Objects for Exchange 2000
  • Microsoft Collaboration Data Objects 2.0 op de volgende platformen
    • Microsoft Windows Server 2003, Standard Edition (32-bit x86)
    • Microsoft Windows 2000 Standard Edition


For a Microsoft Visual Basic Scripting Edition version of this article, see 317680.

INTRODUCTION

This step-by-step article describes how to use an SMTP transport event sink to add a disclaimer to outgoing SMTP e-mail messages.

Create the event sink

  1. Create a new Microsoft Visual Basic ActiveX DLL. Name the project SMTPEventSink, and then name the module Disclaimer.
  2. Under Project References, add Microsoft CDO for Exchange 2000 Library, and then add Server Extension Objects COM Library.
  3. Put the following code in the module:
    Dim TextDisclaimer As StringDim HTMLDisclaimer As String
    Implements IEventIsCacheableImplements CDO.ISMTPOnArrival
    Private Sub IEventIsCacheable_IsCacheable() 'Just returns S_OK.End Sub
    Private Sub Class_Initialize() 'TODO: Replace the sample disclaimer text with your own text. TextDisclaimer = vbCrLf & "DISCLAIMER:" & vbCrLf & "Sample Disclaimer Text." HTMLDisclaimer = "<p></p><p>DISCLAIMER:<br>Sample Disclaimer Text"End Sub
    Private Sub ISMTPOnArrival_OnArrival(ByVal Msg As CDO.IMessage, EventStatus As CDO.CdoEventStatus) If Msg.HTMLBody <> "" Then Dim szPartI As String Dim szPartII As String Dim pos As Integer 'Search for the "</body>" tag and insert the 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
    If Msg.TextBody <> "" Then Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf End If 'Commit the content changes to the transport ADO Stream object. Msg.DataSource.Save EventStatus = cdoRunNextSinkEnd Sub

  4. Replace the sample disclaimer text with your own disclaimer text, and then build the DLL.

Register the event sink

To register the event sink, use the Smtpreg.vbs file that is installed with the Exchange software development kit (SDK).
  1. At a command prompt, locate the \Exchange SDK\SDK\Support\CDO\Scripts folder, and then type the following: cscript smtpreg.vbs /add 1 OnArrival SMTPDisclaimer SMTPEventSink.Disclaimer "mail from=*@your-domain-here.com"

    If this command succeeds, you receive a success message that is generated by the script.
  2. To unregister this event, type the following: cscript smtpreg.vbs /remove 1 OnArrival SMTPDisclaimer
For additional information about managing event bindings, visit the following Microsoft Developer Network (MSDN) Web site:

Test the event sink

To test the event sink, send an e-mail message to an SMTP recipient who is external to your organization. The recipient receives a modified message with the disclaimer text added to the end of the message.

Note If you use a MAPI client, such as Microsoft Outlook, to send the e-mail message, the recipient does not receive a modified e-mail message. This is because the e-mail message that is submitted by using MAPI is not in an SMTP format when the e-mail message triggers the SMTP transport event. Therefore, changes that are made by the code of the event are not persisted.

Referenties


For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

273233
Cannot change MAPI message contents in a CDO SMTP event sink

DoorsturenDoorsturen PrintPrint RSS reactiesRSS reacties BookmarkBookmark

Gekoppelde tags

32-bit, ActiveX, Cache, DLL, Exchange, Exchange 2000, Exchange Server 2003, Outlook, Project, SMTP, Visual Basic, Windows 2000, Windows Server 2003

Reacties
Nog geen reacties geplaatst.

Winkelmandje

Het winkelmandje is leeg

Inloggen
Als u hierboven op de knop 'bestellen' klikt krijgt u een overzicht van de door uw gewenste producten. Indien het overzicht compleet en correct is kunt via de wizard de verdere gegevens invullen en uw bestelling afronden. In het bestelproces kunt u altijd op 'vorige' drukken om terug te gaan in het proces. Bij Perrit staan vertrouwen, privacy en veiligheid op de eerste plaats, wij zullen uw gegevens dan ook met uiterste zorgvuldigheid behandelen en nooit doorgeven aan derden.