Link to home
Start Free TrialLog in
Avatar of rathodr
rathodrFlag for United States of America

asked on

Event Sink not Firing -- What Now??

I have SBS2003 with Exch2003. I installed Metabase Editor 2.2.3 (MS). I copied a VBS sink from MS, registered it (SUCCESS), tied it to the VBS script (SUCCESS) and restarted the Default SMTP server. This actually worked a few days ago so I know it works. My email scanner also worked a few days ago too (AVG Antivirus).

I deleted a dead key using the Metabase Editor and refreshed everything. Monkeyed with the script, unregistered the working copy, registered the new version .. now the VBS script and the Anti-virus do not work (both are supposed to append text messages). Anyway, between the Metabase Editor, the VBS script and registering/unregistering, I am not sure what I screwed up. I am pretty sure it was my fault. I would like to get this back and working.

The email server, otherwise, is working fine. I send an email from yahoo and get it within a minute. The emails come to me unharmed or corrupted.

VBS Script Currently Registered (and not working): filename DetachEmailAtts.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
      'Search for the "</body>" tag and insert our discliamer 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 ' Commit the changes into the transport Stream

   pEventStatus = cdoRunNextSink
End Sub
</SCRIPT>

Registration Command File (working since I can see it in Metabase and using cscript smtpreg.vbs /enum):
cscript smtpreg.vbs /add 1 onarrival SmtpDetachFltr CDO.SS_SMTPOnArrivalSink "mail from=*"
cscript smtpreg.vbs /setprop 1 onarrival SmtpDetachFltr Sink ScriptName "C:\path_to_file\DetachEmailAtts.vbs"

Any ideas?
Avatar of rathodr
rathodr
Flag of United States of America image

ASKER

UPDATE

I decided to check my mail using Outlook. I have been using OWA since this started. In Outlook, the Virus scanner's msg. shows at the bottom of the email (I just sent another email this morning and it is working). So, one question is over.

The script above still does not gen the msg. it is supposed to.

the SMTP event sink won't fire with a MAPI client, when the SMTP event sink is on the mailbox server. Even though the store uses SMTP, it's not a true SMTP transport, it's a pseudo-SMTP transaction. The SMTP event sink for the disclaimer will need to be on a front-end server.

http://support.microsoft.com/default.aspx?scid=kb;en-us;273233

Read this, I think it fits your problem.

D
Avatar of rathodr

ASKER

You know, I read through this before. I thought it really applied to internal email or MAPI client to SMTP. In any case, can you help me setup a border server? Or does this involve redoing the entire Exchange server setup?
ASKER CERTIFIED SOLUTION
Avatar of David Wilhoit
David Wilhoit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rathodr

ASKER

The server is now a bridgehead server and I have seen the DISCLAIMER above on some of the emails. I gen my own emails using telnet xxx.xxx.xxx.xxx 25 and then send a dummy email. I fiddeled around with the msg. format and have a format (formatted) that has worked a few times.

This thing is really flakey. If I make a change, I can't figure out the sequences it likes and does not like. In any case, I would eventually like to detach files automatically. So, if an email comes in with a specific format, and a specific filename in the attachment, then I would like to detach the file and save it to the hard drive.

What might I try? Any help would be appreciated.
Avatar of rathodr

ASKER

Kidego,

I got it working! The problem was really subtle (at least to an old C programmer). I am writing this in VB Script, but when I added an if loop to the above script, I used "endif" to close it. Looked good to me, right? Well, VBScript uses "end if" (with a space between the two separate words) as the correct syntax.

When I fixed this, I get my disclaimers and the new code working consistently and accurately.

Thank you for taking time to answer my question.
Congrats!