How to Receive Email Alerts from MailStore if an Archive Job Fails

Will MailStore alert me when a job fails?

Of the many queries I see as a member of the MailStore support team here at Zen Software, this is one of the more common ones.

Unfortunately, for the time being at least, this isn’t something you can do from within the software but fear not – the reason for my post is that there is a workaround.

EDIT: Email reporting was introduced in v10.1 – more information here.

First, a couple of checks…

Before I start showing you the configuration steps, first we need to check the following is happening.

Check 1) It’s Windows 7/ 8/ 2008 or 2012 that we’re running

Check 2) MailStore is configured to store events in the Windows event log instead of the file system.

Check 3) The email account used to send the email alerts doesn’t containt a ‘$’ sign in it (well, you never know!).

Ok, with those out of the way we can move on to configuration.

Activating the auditing features

This method of alerting works by monitoring the MailStore audit events that are generated by the software and written to the Windows event log.

In order to generate these you must first enable the feature within MailStore:-

  1. Open the MailStore Client as administrator.
  2. Click on Administrative Tools > Compliance > Auditing.
  3. Activate the user activity ProfileRunArc.

UPDATE: On version 9 and above of MailStore you will also need to check that the Audit logs are being written to the Windows Event log not to a file log.

This can be set within the ‘Configure the MailStore Server Service” tool

Now, after archiving profiles have been executed, you’ll find the corresponding entries are being made in the event log.

How to check the Windows event logs manually

  1. Open the Event Viewer of your Windows system.
  2. Click on Event Viewer (local) > Windows Protocols > Applications.
  3. Search for events of source MailStore Server Auditing.

If errors occurred while executing the profile, the event level is Error. If the execution was successful, the level is Information.

In the next section we will monitor the log for any errors and trigger an email.

Setting up your notifications

In this example we’ll be using the Windows task scheduler to monitor for a specific event and then trigger a process off the back of it.

Let’s say you want to send an email when an ‘Archiving Failed’ event is written to the log. This is how you could go about doing it:

  1. Open the Task Scheduler of your Windows system
  2. Create a new folder, e.g. MailStore Auditing in the Task Scheduler Library
  3. Create a task via Actions > Create Task
  4. Please note that you will not Create a Simple Task
  5. Enter a meaningful name such as ‘MailStore Archiving Error’
  6. Select the option ‘Run whether user is logged on or not
  7. Under Configure for, select Windows Vista or Windows Server 2008 (otherwise the ‘Trigger On’ event is not available)
  8. Click on the ‘Triggers’ tab
  9. Click on ‘New’
  10. Under ‘Start Task’ select the value ‘On Event’
  11. Under ‘Settings’, activate the option ‘Custom’ and click on ‘New Event Filter’
  12. Under ‘Event Level’ place a check mark next to ‘Error’
  13. Select ‘Via Source’ and under ‘Sources’ place a check mark next to ‘MailStore Server Auditing’
  14. Click on ‘OK’ to save the settings
  15. Change to the ‘Actions’ tab
  16. Click on ‘New’

Use PowerShell to set up alert email 

Before we can select the PowerShell script to run, we must first create it. Open Notepad and add the following content (be sure to adjust the values in red according to your mail environment):-

$EmailFrom = “mailstore@yourdomain.com”
$EmailTo = “administrator@yourdomain.com”
$Subject = “MailStore Error”
$Body = “Please check MailStore Server logs”
$SMTPServer = “smtp.yourdomain.com”
$SMTPPort = 25
$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$SMTPClient.EnableSsl = $false
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, “password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Once edited, save the script as c:\email-alert.ps1 (you may choose a different path for this). Now switch back to the task scheduler window:

  1. In the ‘Action’ field select ‘Start’ a program.
  2. As ‘Program/script’ enter ‘powershell.exe’
  3. As argument enter the path to the Powershell script e.g c:\email-alert.ps1
  4. Click ‘ok’ to save the Task.

Before we can run the script, the execution of scripts has to be enabled.

To do this so open Windows PowerShell and enter the command.

Set-ExecutionPolicy RemoteSigned

Lookout for those backup jobs

When I first set this up I was actually caught out straight away – immediately I was getting an error appearing every day at 7pm.

I could immediately rule out it being a random glitch and soon narrowed it down to being something outside of the control of MailStore. As it happened, eventually it twigged that it was our backup software interfering with the job each day.

Even though this backup was successful, the act of triggering the MailStore VSS writer must stop the current job running and therefore triggered the alert.

The simple fix was to exclude the time the backup job ran from the archive jobs ‘Automatic Mode’ so keep that in mind if you see the same error happen,

Let me know how you get on!

As always, I hope that’s something you can use – feel free to get in touch in the normal ways or leave a comment below if you’ve got a question.

Let us know what you think....

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s