“How to Raise Alert from Microsoft Outlook in OpsMgr 2007” or a New Outlook Connector to Operations Manager 2007 R2
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 http://blog.coretech.dk/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)
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
2. Open visual Basic
3. Select “ThisOutlookSession”
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
5. Create rule in outlook
6. Select the coditions you want. Or none to process all emails
7. Select “run as Script” in the Select actions window, and choose the sub you have just created
8. Define exceptions if you have any, otherwise leave it blank.
9. Give your rule a name and save it.
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:
And the script to paste in the code window: (feel free to make it your way)
On Error Resume Next
Dim objAPI, objBag, objFSO, strTargetFolder, objFolder
Dim folderIdx, objFile, strDoneFile, arrFileLines
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Set objAPI = CreateObject(“MOM.ScriptAPI”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
strTargetFolder = “c:\Temp\Mails”
Set objFolder = objFSO.GetFolder(strTargetFolder)
IF Err.Number > 0 Then
Call objAPI.LogScriptEvent(“ReadMail.vbs “,0, EVENT_TYPE_ERROR ,”Folder ” & strTargetFolder & ” was not found.”)
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)
3. Create an Alert Generating Event Rule
Create a new rule – remember the Management Pack
Please, disable the rule and create an override afterwards.
And the override on the Windows/Outlook client:
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
Have a nice day