?
Solved

Create a live monitoring screen to display data from VBScript?

Posted on 2011-03-03
9
Medium Priority
?
581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 35032805
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
ID: 35037095
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
ID: 35045211
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:tabush
ID: 35194229
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 35194660
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
ID: 35199167
rob - best we discuss this directly - can you email me mtabush [at] tabush [dot] com
0
 
LVL 11

Expert Comment

by:Ove
ID: 35200062
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
ID: 35200222
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
ID: 35204692
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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