Technical Article

Net Send

,

Yee Haa, as if we couldn't annoy our users more with message boxes, emails, and other friendly pop ups ;P here comes the net send. Has a test for success to determine if the send worked. If an invalid name is entered it can take a bit to fail, so don't use this from a time sensitive call. See the net send help in NT for mor help on using. Also if your users are using Win 9X they will not recieve any net sends unless they are running win pop up. Search MSFT for winpopup documentation.

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.spNetSend    Script Date: 12/18/2002 9:14:03 PM ******/
ALTER  PROCEDURE spNetSend(@username varchar(100) = '*', 
@msg varchar(4000) = '',
@RetCode bit = 0 OUTPUT)
AS
DECLARE @netsend nvarchar(4000)

CREATE TABLE #netSend (outputData varchar(7800))

SET @netsend = 'net send ' + @username + ' ' + @msg

INSERT INTO #netSend EXEC master..xp_cmdshell @netsend

IF EXISTS(select * from #netSend where output like 'The message was successfully sent%')
SET @RetCode = 1
ELSE
SET @RetCode = 0

DROP TABLE #netSend


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  EXECUTE  ON [dbo].[spNetSend]  TO [public]
GO

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating