Have you ever thought on creating Alerts directly from a mail? Or Send a mail to your OpsMgr to raise an alert in your Operations Manager?

A few weeks ago I was talking with a guy participating on one of the Advanced OpsMgr courses, his existing monitoring environment currently delivered an mail to a group mailbox in which they used to react and resolve issues from a Nagios/IPMonitor installation. But what he really would like to was gather all issues in the Operation Manager Console, after a quick talk with Jakob Svendsen https://blog.ctglobalservices.com/jgs/outlook-2010-auto-export-body-of-new-e-mails/ he came up with a “How To” create text files directly from Outlook. I will also use Jakob’s step by step Outlook configuration as the first step in this three step configuration:

First the Prerequisite:

· Operations Manager 2007
· A client or server with an OpsMgr agent and Outlook 2007/2010
· Notepad (Or your favorite vbs editor)

In short:

1) Configure Outlook to save a text file every time a mail arrives
2) Create a Timed Rule which gather all text files and raise Alerts
3) Create an Event Monitor which react on the alert create in step 2.

1. Outlook Configuration:

1. Enable Developer Ribbon to be able to create scripts

clip_image002

2. Open visual Basic

clip_image003

3. Select “ThisOutlookSession”

clip_image004

4. Type/ this Sub into Visual Basic. Changed the strExportPath to the folder you want to use.

Sub SaveMessageOnRule(Item As Outlook.MailItem)
Dim strExportPath As String
strExportPath = “C:\Temp\Mails\”
Dim FileName As String
FileName = strExportPath & Replace(Replace(Replace(Now & “_” & Item.EntryID & “.txt”, “:”, “_”), “-“, “_”), ” “, “_”) ‘Create filename and path, replace : with _, …
Dim FileNum As Integer
FileNum = FreeFile ‘ next file number
Open FileName For Output As #FileNum ‘ creates the file if it doesn’t exist
Print #FileNum, Item.Body ‘ write information at the end of the text file
Close #FileNum ‘ close the file
End Sub

5. Create rule in outlook

clip_image005

6. Select the coditions you want. Or none to process all emails

clip_image007

7. Select “run as Script” in the Select actions window, and choose the sub you have just created

clip_image009

8. Define exceptions if you have any, otherwise leave it blank.

clip_image011

9. Give your rule a name and save it.

clip_image013

10. You are now ready to setup the managementpack – Test it and be sure you get an email in the specified folder.

2. Create a Timed Script Rule

After this is done create a Timed Script Rule in Operations Manager by following this guide:

image

image

image

image

And the script to paste in the code window: (feel free to make it your way)

Option Explicit
On Error Resume Next
‘=========================================
‘Declare Variables
‘=========================================
Dim objAPI, objBag, objFSO, strTargetFolder, objFolder
Dim folderIdx, objFile, strDoneFile, arrFileLines

‘=========================================
‘Declare Constants
‘=========================================
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

‘=========================================
‘Create Objects
‘=========================================
Set objAPI = CreateObject(“MOM.ScriptAPI”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
strTargetFolder = “c:\Temp\Mails”
Set objFolder = objFSO.GetFolder(strTargetFolder)
‘=========================================
‘Intelligents…
‘=========================================
IF Err.Number > 0 Then
Call objAPI.LogScriptEvent(“ReadMail.vbs “,0, EVENT_TYPE_ERROR ,”Folder ” & strTargetFolder & ” was not found.”)
Else
For each FolderIdx In objFolder.Files
Set objFile = objFSO.OpenTextFile(FolderIdx.Path, 1)
Set strDoneFile = objFSO.GetFile(FolderIdx.Path)
arrFileLines = objFile.ReadAll
Call objAPI.LogScriptEvent(“Test From ErrorMail”,666, EVENT_TYPE_Warning, arrFileLines)
objFile.Close
strDoneFile.Delete
Next

End IF

3. Create an Alert Generating Event Rule

Create a new rule – remember the Management Pack

image

Please, disable the rule and create an override afterwards.

image

image

image

image

And the override on the Windows/Outlook client:

image

image

image

And Voila – now you recieve all alerts from outlook, and the best thing is that you yourself can create Alerts directly by emailen the user. So in need for any Alerts Winking smile

Have a nice day
Kåre