You are here: MessengerYouLike.IMSDK > IMSDK Reference > IMSDK Namespace > Classes > IMClient Class > IMClient Methods > IMClient.BeginSendMessage Method
MessengerYouLike
IMClient.BeginSendMessage Method

This Method Allows Users to send a Message to Online and Offline Contacts

C#
public BeginSendMessage(String FriendUsername, String Message);
Visual Basic
Public Sub BeginSendMessage(ByVal FriendUsername As String, ByVal Message As String)
Parameters 
Description 
ByVal FriendUsername As String 
Username of the Contact to Which message should be Sent 
ByVal Message As String 
Message For the User 

Users can Send Messages to Both Online and Offline Contacts, there Message can be in any Language this method Takes care of all Language encoding 

 

When Message is delivered Successfully then event IMSDK.IMClient.OnMessageDelivered is fired 

and when Message Could Not be Delivered Due to network problems then Event IMSDK.IMClient.OnMessageNotSent is fired 

 

when a message is queued as a offline message a event IMSDK.IMClient.OnOfflineMessageQueued is fired 

 

Message is Stored as Offline Message When 

 

1 - When users Logs out Calling IMSDK.IMClient.BeginLogOut then all Messages Sent will be Offline Messages and then Next time that users Logs in they get all offline Messages by the event IMSDK.IMClient.OnOfflineMessageReceived 

 

2- When users Closes the application or get Disconnected from the internet with out calling IMSDK.IMClient.BeginLogOut then the First Message will raise the event IMSDK.IMClient.OnMessageNotSent and then all Contacts will be notified that Contact is Offline and any messages sent after that will be Offline Messages 

 

 

 

When a contact is blocked [ IMSDK.IMClient.BeginFriendBlockUnBlock ] then the message is never sent to the server so when a contact is blocked then no messages should be sent to the friend wether online or offline 

 

if the friend property IMSDK.Friends.MFriend.AmIBlocked or IMSDK.Friends.MFriend.Blocked any of these is true then no messages will be sent to the server and no event will be fired , means if the logged in user is blocked by the friend or the friend is block by the logged in user then no communication is allowed between these two users 

 

if the logged in user changes it's status [ IMSDK.IMClient.Status ] to Offline [ IMSDK.IMClient.Status.Offline ] and is still connected to the IM Server then any message sent to that Connected Contact whose Status [ IMSDK.IMClient.Status ] is set to Offline [ IMSDK.IMClient.Status.Offline ] will be queued as offline messages changing the status [ IMSDK.IMClient.Status ] to online will NOT show offline messages until the user logs out and logs in again

[Visual Basic]
 
'Create a new IMClient
Dim MC as new IMSDK.IMClient
 
 
 
'Call the Listen Sub
MC.Listen()
 
 
 
'Now Try to login
MC.BeginLogin(TxtUsername.Text,TxtPassword.Text)
 
 
 
'if username and password is valid then
Private Sub MC_OnLoggedin(ByVal UserObject As IMSDK.User) Handles MC.OnLoggedin
    Debug.WriteLine("Username logged in : " & MCUser.Username & " , " & MCUser.Password)
End Sub
 
 
 
'if username or password is invalid then
Private Sub MC_OnUsernameOrPasswordInvalid(ByVal Username As String, ByVal Password As String) Handles MC.OnUsernameOrPasswordInvalid
  Debug.WriteLine("Username password invalid : " & Username & " , " & Password)
End Sub
 
 
 
'Now Send Message
 MC.BeginSendMessage(TxtUserName.Text,TxtMessage.text)
 
 
 
'When Message Is delivered Successfully
    Private Sub MC_OnMessageDelivered(ByVal Friendusername As String, ByVal Message As String, ByVal DeliveredDate As Date) Handles MC.OnMessageDelivered
       Debug.WriteLine("Message Sent to: " & Friendusername & " Message : " & Message & " Datetime was : " & DeliveredDate.ToString)
    End Sub
 
 
 
'When a Message Could Not Be delivered due to network problems
     Private Sub MC_OnMessageNotSent(ByVal Friendusername As String, ByVal Message As String) Handles MC.OnMessageNotSent
        Debug.WriteLine("Message could not be delivered  to: " & Friendusername & " Message : " & Message)
    End Sub

 

Copyright (c) 2007. All rights reserved.