Click to See Complete Forum and Search --> : send a message to another user-rather simple
rsmall
Aug 20th, 2001, 12:59 PM
I want to be able to send a message to another computer on the network the way that you can with using the NET.EXE at the command line as in the format:
net send "<user>" "<message>"
I have the both the username and message in variables. Can someone help me with this?
Thanks,
Ryan Small
Matthew Gates
Aug 20th, 2001, 07:03 PM
Try both of these ways:
Shell "net send " & user & Chr$(32) & message
Or:
Shell "command.com /c net send " & user & Chr$(32) & message
matbrophy
Aug 21st, 2001, 04:55 PM
:confused: is there away of executing dos commands without the dos window appearing?:confused:
Matthew Gates
Aug 21st, 2001, 07:56 PM
You can hide the window.
Shell "net send " & user & Chr$(32) & message, 0 'or vbHide
SjR
Aug 22nd, 2001, 06:18 AM
Does any one no if its possible to send a message to a computer that has the messenger service disabled (temporarily enable and then disable afterwards?) BTW, Logon scripts is not an option.
Thanks
:D
Frans C
Aug 22nd, 2001, 01:43 PM
To send a network message using visual basic code, use the netMessageBufferSend api.
In a .bas module:
Private Declare Function NetMessageBufferSend Lib "netapi32" (ByVal ServerName As String, ByVal msgname As String, ByVal fromname As String, ByVal msgbuf As String, ByRef msgbuflen As Long) As Long
Private Const ERROR_ACCESS_DENIED As Long = 5
Private Const ERROR_BAD_NETPATH As Long = 53
Private Const ERROR_INVALID_PARAMETER As Long = 87
Private Const ERROR_NOT_SUPPORTED As Long = 50
Private Const ERROR_INVALID_NAME As Long = 123
Private Const NERR_BASE As Long = 2100
Private Const NERR_Success As Long = 0 'success
Private Const NERR_NetworkError As Long = (NERR_BASE + 36) 'general network error occurred.
Private Const NERR_NameNotFound As Long = (NERR_BASE + 173) 'message alias could not be found on the network.
Private Const NERR_UseNotFound As Long = (NERR_BASE + 150) 'network connection could not be found.
Public Function NetSendMessage(ByVal sMessage As String, ByVal sTo As String, ByRef errMessage As String, Optional sFrom As String, Optional Server As String) As Boolean
Dim retVal As Long
If Len(Trim(sTo)) > 0 Then
sTo = StrConv(sTo, vbUnicode)
If Len(sMessage) = 0 Then
sMessage = vbNullString
Else
sMessage = StrConv(sMessage, vbUnicode)
End If
If Len(sFrom) = 0 Then
sFrom = vbNullString
Else
sFrom = StrConv(sFrom, vbUnicode)
End If
If Len(Server) = 0 Then
Server = vbNullString
Else
Server = StrConv(Server, vbUnicode)
End If
retVal = NetMessageBufferSend(Server, sTo, sFrom, sMessage, ByVal Len(sMessage))
NetSendMessage = retVal = 0
Select Case retVal
Case ERROR_ACCESS_DENIED
errMessage = "Access denied"
Case ERROR_BAD_NETPATH
errMessage = "Bad network path"
Case ERROR_INVALID_PARAMETER
errMessage = "Invalid parameter"
Case ERROR_NOT_SUPPORTED
errMessage = "not supported"
Case ERROR_INVALID_NAME
errMessage = "Invalid name"
Case NERR_NetworkError
errMessage = "General network error"
Case NERR_NameNotFound
errMessage = "Message alias could not be found on the network."
Case NERR_UseNotFound
errMessage = "Network connection could not be found."
Case NERR_Success
errMessage = "Operation succeeded"
Case Else
errMessage = "Unknown error"
End Select
Else
NetSendMessage = False
errMessage = "No recipient selected"
End If
End Function
To receive the message, the recipient needs to run a messenger service. A messenger service is basically not more then a program that periodically checks the messenger mailslot "\\.\mailslot\messngr" for files, and displays the contents of the file in a messagebox.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.