• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

Create a live monitoring screen to display data from VBScript?

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
tabush
Asked:
tabush
  • 4
  • 4
1 Solution
 
RobSampsonCommented:
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
 
tabushAuthor Commented:
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
 
RobSampsonCommented:
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
Independent Software Vendors: 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!

 
tabushAuthor Commented:
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
 
RobSampsonCommented:
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
 
tabushAuthor Commented:
rob - best we discuss this directly - can you email me mtabush [at] tabush [dot] com
0
 
OveCommented:
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
 
tabushAuthor Commented:
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
 
RobSampsonCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now