Solved

Create a live monitoring screen to display data from VBScript?

Posted on 2011-03-03
9
557 Views
Last Modified: 2012-05-11
we have an outlook mailbox that i want to be able to keep track of how many unread messages there are (in several folders) on a "big screen"

i found this article http://support.microsoft.com/kb/171603 which explains how to use visual basic to report back the # of unread messages in a folder. my thought is to maybe have a "monitoring board" screen created in flash or silverlight which reads the data and displays it, refreshing it every minute or two.
it can also be regular HTML i guess, as long as it is refreshing on a regular basis.

does anyone know if this is possible, and maybe can point me in the right direction? then i can hopefully get a programmer (from a service like odesk or vworker) to create it for me.
0
Comment
Question by:tabush
  • 4
  • 4
9 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
Hi, I can't test this because I don't use Outlook, but see if this works.  It's a HTA file.  Save it as a HTA file, and run it.  It should connect to your Outlook instance, and display the Unread item count of the specified folder, then refresh it at the Timer interval.

Regards,

Rob.
<html><head><title>Test</title>
<HTA:APPLICATION
ID = "Test"
APPLICATIONNAME="Test"
>
<head>
<script language='vbscript'>
	Sub Window_Onload
		iTimerID = window.setInterval("Main", 10000)
	End Sub

	Sub Main
		MyForm.InnerHTML = ""
		Const FOLDER_TO_OPEN = "Mailbox - John Doe"   'Modify as appropriate
		Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
		Call PrintFolderNames(olMAPI.Folders(FOLDER_TO_OPEN), "->")
		Set olMAPI = Nothing
	End Sub
	
	Sub PrintFolderNames(tempfolder, strSep)
		Dim i As Integer
		If tempfolder.Folders.Count Then
			MyForm.InnerHTML = MyForm.InnerHTML & "<BR>" & strSep & " " & tempfolder.Name & "  "
			MyForm.InnerHTML = MyForm.InnerHTML & "<BR>" & tempfolder.UnReadItemCount
			For i = 1 To tempfolder.Folders.Count
				Call PrintFolderNames(tempfolder.Folders(i), strSep & "->")
			Next i
		Else
			MyForm.InnerHTML = MyForm.InnerHTML & "<BR>" & strSep & " " & tempfolder.Name & "  ";
			MyForm.InnerHTML = MyForm.InnerHTML & "<BR>" & tempfolder.UnReadItemCount
		End If
	End Sub

	Sub HTASleep(intSeconds)
		Set objShell = CreateObject("WScript.Shell")
		objShell.Run "ping 127.0.0.1 -n " & intSeconds + 1, 0, True
	End Sub
</script>
</head>
<body>
<span id="MyForm"></span>
</body>

Open in new window

0
 
LVL 2

Author Comment

by:tabush
Comment Utility
Wow thanks Rob!
I'm actually looking to do a little bit more - ideally return the unread count to a local text file or database or something, and then i'd have the Flash/Web developer read those values and "animate" the screen/webpage/counters based on the number... for example, flash if a number is over 5, beep whenever it increases, etc.

any ideas how to build a very simple database (maybe 2 fields - foldername and newcount) and keep that up to date, refreshing every 30 seconds or so?
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Does it need to be a database?  Or do you need it for historical records?  The HTA can easily write to a database, so that's no big deal.  And, being HTML code, the HTA can also do a bit of animation, even if it were just displaying an animated GIF when the unread count increased over 5.  Does that sound OK?

What type of database?  Access?  SQL?

Regards,

Rob.
0
 
LVL 2

Author Comment

by:tabush
Comment Utility
sorry for delayed response. actually no i don't need a database, i just need the data so i can display it on a "big board".
if it can write to a CSV file, i can then create a flash object to constantly read that CSV file and display the data on a web page. and it can just keep re-running every 60 seconds and update/replace the existing CSV file, so my flash system will re-read the data.

rob - if you can do this without flash, and it sounds like you can... email me mtabush@tabush.com - i'd be willing to pay you something if you can make it work!
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, well, if you don't mind the HTA interface, then you can just go ahead and customise the HTML code within it to produce something pretty.

Or, instead of writing to MyForm.InnerHTML, we can make it write to a CSV, so you can use your Flash object to read from that....

It's really up to you.  You could just run the HTA on the big screen if that's what you want.

Unfortunately I can't test the interface at all, because I don't use Outlook.

What are your thoughts on how you want the interface to look?

Rob.
0
 
LVL 2

Author Comment

by:tabush
Comment Utility
rob - best we discuss this directly - can you email me mtabush [at] tabush [dot] com
0
 
LVL 11

Expert Comment

by:Ove
Comment Utility
Hi tabush,
pls keep in mind that EE is also used as knowledge-base for others - which might be interested in solutions.
So an open discussion is always better for the whole community :-)

Ove
0
 
LVL 2

Author Comment

by:tabush
Comment Utility
no problem.
i'm very technical in systems but not programming/html.
i'm thinking one main webpage which is split into about 12 "sections" - maybe 4 across by 3 down. each section representing a specific folder in outook, and it shows the name of the folder and in big, the # of unread emails.
it doesn't have to be flash, regular HTML is fine.
refresh every 60 seconds is nice.
maybe for some animations/colors:
if no unread emails, display 0 in green
if 1-10, display # in black
11+, red
21+ display in red and flashing, or some animation, or something to call attention to it.


i will have a computer with outlook always open so your system can pull the "unread counts" from it. it can have whatever version of outlook you prefer (2003-2010). the whole system can be self-contained on there including the script and the web server (iis?), or we can use an external system (windows or linux) to pull the info from outlook and serve it up as a webpage.

would also be nice if i can change it to a different grid layout, maybe 4x2 or 3x3, as i don't know if i need 12 folders to be monitored or not.

let me know your thoughts and how to proceed.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Ok, well as a proof of concept (as I can't use Exchange or Outlook), can you save the below code into a file called UnreadEmailMonitor.hta, then change the folder names in arrFolders to suit your folder names.

When you run it, have Outlook open, and see what happens.  Hopefully, it will list (rather boringly) the unread count from each folder, in HTML, with a maximum column count of 4, but a row count as long as required.

Let me know how it goes....we can add colours and animations to it if it goes well.

Regards,

Rob.
<html><head><title>Test</title>
<HTA:APPLICATION
ID = "Test"
APPLICATIONNAME="Test"
WINDOWSTATE="maximize"
>
<head>
<script language='vbscript'>
	Dim arrFolders, intWidth, intHeight, olMAPI
	
	Sub Window_Onload
		arrFolders = Array("Inbox1", "Inbox2", "Inbox3")
		intMaxWidth = 4
		
		intCells = UBound(arrFolders) + 1
		intWidth = RoundUp(Sqr(intCells))
		If intWidth > intMaxWidth Then intWidth = intMaxWidth
		intHeight = RoundUp(intCells / intWidth)
		
		iTimerID = window.setInterval("Main", 60000)
		
		Main
	End Sub

	Sub Main
		Display.InnerHTML = ""
		'Const FOLDER_TO_OPEN = "Mailbox - John Doe"   'Modify as appropriate
		Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
		PrintFolderEmailCount
		'Call PrintFolderNames(olMAPI.Folders(FOLDER_TO_OPEN), "->")
		'Set olMAPI = Nothing
	End Sub

	Sub PrintFolderEmailCount
		strHTML = "<table border=1 width='100%' height='100%'>"
		strHTML = strHTML & VbCrLf & "<tr><td align='center' height='20%' colspan='" & intWidth & "' style='font-size:32pt;'>EMAIL UNREAD COUNT</td></tr>"
		intFolder = 0
		For intRow = 1 To intWidth
			strHTML = strHTML & VbCrLf & "<tr>"
			For intCol = 1 To intHeight
				If intFolder <= UBound(arrFolders) Then
					strHTML = strHTML & VbCrLf & "<td align='center'><table><tr><td align='center'>" & arrFolders(intFolder) & "</td></tr><tr><td align='center' style='font-size:48pt;'>" & GetUnreadCount(olMAPI.Folders(arrFolders(intFolder))) & "</style></td></tr></table></td>"
				Else
					strHTML = strHTML & VbCrLf & "<td align='center'>&nbsp;</td>"
				End If
				intFolder = intFolder + 1
			Next
			strHTML = strHTML & VbCrLf & "</tr>"
		Next
		strHTML = strHTML & VbCrLf & "</table>"
		Display.InnerHTML = strHTML
	End Sub

	Function RoundUp(dblNumber)
		RoundUp = Int(dblNumber+(Abs(Fix(dblNumber)<>dblNumber)))
	End Function
	
	Function GetUnreadCount(tempfolder)
		GetUnreadCount = tempfolder.UnReadItemCount
	End Function

	Sub HTASleep(intSeconds)
		Set objShell = CreateObject("WScript.Shell")
		objShell.Run "ping 127.0.0.1 -n " & intSeconds + 1, 0, True
	End Sub
</script>
</head>
<body>
<span id="Display"></span>
</body>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now