Home > Service Manager > Service Manager E-mail pre-processor Service

Service Manager E-mail pre-processor Service

February 14, 2011 Leave a comment Go to comments

In early November 2010, a good two months before the Service Manager Exchange Connector was released, I needed to provide an incident e-mail handling solution for a client.  I looked at and was inspired by Anders Bengstsson solution but wanted something more robust, so I decided to write a Windows service that uses file system watchers and multiple worker threads.

So why post this now after the Service Manager Exchange connector has been released?  Well, because someone out there might find it useful – someone who maybe doesn’t use Exchange (gasp 🙂 )or uses a version of exchange prior to Exchange 2007, or maybe even just wants a quite simple solution.

The Service Manager E-mail Pre-processor service works by intercepting SMTP mail before it gets to Service Manager.  The .eml files are properly parsed using Collaborative Data Objects (CDO) for Windows and the subject line is further parsed for incident tokens.  If incident tokens are present, the incident ID is parsed and used to update the incident.  The first 4000 characters of the email body are added as a comment to the incident, and the eml file is added as an attachment.  If incident tokens are not present, the e-mail is moved into another folder from which Service Manager reads.

Configuring and Installing the Service

The Service Manager E-mail pre-processor service can be installed and run from any Windows computer running The .Net 3.5 framework.

Download the SMEmailPreProcessor.zip file, which contains the following files

  • SMEmailPreProcessor.exe
  • SMEmailPreProcessor.exe.config
  • Microsoft.EnterpriseManagement.ServiceManager.dll
  • Microsoft.EnterpriseManagement.Packaging.dll
  • Interop.CDO.dll
  • Interop.ADODB.dll

Extract all files into the same folder.  Using a text or XML editor, open SMEmailPreProcessor.exe.config and edit the settings under the <SMEmailPreprocessor.Properties.Settings> node.  Each setting name is shown as

<setting name=”Setting_NameserializeAs=”string”> and the settings value is within the <value> </value> tags.

The settings are:

  • DropFolder”: This is the SMTP drop folder for the Service Manager SMTP domain.  This like other settings folders can be a local or UNC path
  • NewIncidentFolder”: This is a new folder you need to create.  After parsing each .eml file, if the service determines that the e-mail is not an incident reply e-mail, the .eml file is moved into this folder to be picked up by Service Manager.  Note that you must edit Incident Incoming E-Mail settings in Service Manager to specify this folder as the SMTP Drop folder, rather than the default drop folder above.
  • IncidentTokenStart“: This token denotes the start of the incident ID in the e-mail subject line.  Any characters after this start token and before the end token (below) will be read as the incident ID.  The start token can be one or more characters.  Be sure to use unique characters that would typically not be used in an e-mail subject.
  • IncidentTokenEnd“:  This token denotes the end of the incident ID in the e-mail subject line.  If you use the sample start token of [# and the sample end token of ] , the incident ID in the subject line would be something like [#IR3612] where the incident ID is IR3612.
  • IncidentComment“:  You generally want to leave the value for this setting blank.  Any value you specify here will be used instead of the e-mail body as the incident comment.
  • BadMailFolder“:  Where to place .eml files that could not be processed.
  • ManagementServer“:  The Service Manager management server name.  If the service runs locally on the management server, leave the value as localhost.
  • Verbose“:  Leave this value set to False.  Make it True only if you are troubleshooting a problem.


After modifying the .config file, you need to install the service. The service needs to run with a domain account.  The account must have permissions to read & write to the SMTP folders specified in the .config file, and must have Incident Resolver permissions in Service Manager.  To install the service, open an elevated command prompt at the folder with the extracted files and run:

\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe SMEmailPreProcessor.exe

The assembly installer will prompt you to specify a service login and password.  The installation is logged to InstallUtil.InstallLog in the same folder.  The file can be opened with notepad.  After successful installation, you can start the service using Services.msc.  The service name is “SM Email Preprocessor”. 

Remember that before starting the service, you must change the Service Manager Incident Incoming E-Mail settings to the value specified as the “NewIncidentFoder”.

The service logs to the Windows application event log, event source ‘SMEmailPreprocessor’.


Uninstalling the Service

Open an elevated command prompt at the folder with the service executable and run:

\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe /u SMEmailPreProcessor.exe

You’d then want to restore the Service Manager Incident Incoming E-Mail settings to the default SMTP drop folder.

Categories: Service Manager
  1. July 2, 2011 at 2:08 pm

    Thank you for the information, this is really helpful for me. Hope there will be more in the coming days.

    Ashok Sunar
    Student in IOE
    Pokhara, Nepal

  2. Richard Hobbs
    September 13, 2011 at 7:53 am

    Thanks you for this.
    i have got it working to pass through a new incident, but when it tries to update an existing incident i get the following error in the event log:

    Update thread: Exception from Service Manager library: Specified argument was out of the range of valid values. Parameter name: index

    Do you have any idea what could cause this.


    • Kan
      September 19, 2011 at 5:33 pm

      Verify that the incident id is surrounded by the proper tokens (defaults are [# and ] e.g. [#IR333]). If necessary, set the value of ‘Verbose’ to ‘True’ in SMEmailPreprocessor.exe.config and restart the service. Verbose logging shows information that is normally not logged, and may reveal where the problem is.

      • Richard Hobbs
        October 27, 2011 at 7:35 am

        Hi, thanks for your reply.

        I have confirmed the tokens are correct. I should have said above that i have turned on verbose logging and that error comes from the verbose logging. That is the only error that is logged. There are 7 informational alerts logged before the error that say it is opening the update thread, and updating the correct incident ref etc.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: