Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

       How did you like this article? Please vote and let us know.          

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Shannal L. Thomas
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath

 

 
 

WSS Version of IM Announcements to all user with an Exchange mailbox    Download scripts

This is a port of the script I described in a previous article IM Announcements to all user with a Exchange mailbox using an On_Arrival SMTP event sink. This version uses a WSS Async On_Save event sink and adds the functionality of a header for the announcement to say who it has come from.

How it works

I've used a two step approach to firing this event that adds a layer of abstraction for my Exchange event sinks. the event sink code look as follows it uses a Async onsave event sink.

<SCRIPT LANGUAGE="VBScript">

Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)

Stm = bstrURLItem
set WshShell = CreateObject("WScript.Shell")
strrun = WshShell.run ("c:\evtsink\sndmsg3.vbs " & stm)
set WshShell = nothing
End Sub

</SCRIPT>

Main Script

Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1
   if I = 0 then
	inbstr = objArgs(I)
   else
	inbstr = inbstr & " " & objArgs(I)
   end if
Next
Dim ADODBRec
Set Rec = CreateObject("ADODB.Record")
rec.Open inbstr
message = "Annoucement from " & rec.Fields("urn:schemas:httpmail:sendername") & vbCrLf
message = message & " " & rec.Fields("urn:schemas:mailheader:subject")
set OU = GetObject("LDAP://CN=Users,DC=AD1")
dim strtest, loopexit
loopexit = 1
call sendmsg()
sub sendmsg()
	strMsgHeader = "Mime-Version: 1.0" & vbCrLf & "Content-Type: text/plain; charset=UTF-8" & vbCrLf & vbCrLf
	msgType = IM_MSG_TYPE_NO_RESULT
	Set oIMApp = CreateObject("MSExchangeIM.MSIMHost")
	Set oIMServ = oIMApp.CreateContext("Default", 0)
	strtest = Array("newb1@exbend","newb1","pass","ad1")
	oIMServ.logon strtest
	do until iState = 2
		oIMServ.GetLocalState iState, strState, strDescr
		if loopexit = 1000 then
			exit sub
		end if
		loopexit = loopexit + 1
	loop
	For Each oUser in OU
		if oUser.Class = "user" then
			if oUser.msExchIMAddress <> "" then
    				set oIMsession = oIMServ.CreateIMSession(oUser.msExchIMAddress)
				oIMsession.Sendtext strMsgHeader, message, msgtype
				On Error resume Next
			End If
		End If
	Next
	Set OU = Nothing	
	OIMServ.logoff()
	set oIMApp = nothing
end sub
 

Registering this script

For details on installing and registering this script see my previous article Using VBS Event Sink scripts with the Web Storage System. Or have a look in the ESDK search for regevent.vbs    Download scripts


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Pro Exchange. OutlookExchange.Com and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

© Copyright Pro Exchange, Inc., 2006