MSN Messeger

Can I make an application using Visual Basic 2005 that can control some functions in MSN messeger 7.5 If yes can you send me the code. I think that I need some dlls to make it happen.
Thanks Glenn Zarb


Answer this question

MSN Messeger

  • Dee_dotnet_79

    In future you may want to look into one of the many C# to VB.NET converters that are online... and using one of them and a few hand made changes the code from the previous link becomes:

    Imports Interop.Messenger

    Sub Form1_Load(sender As Object, e As System.EventArgs) '

    'This next line creates our Messenger Class
    Dim Msgr As New MsgrObjectClass()

    'These 3 lines create the events to be used
    AddHandler Msgr.OnTextReceived, AddressOf Me.OnTextReceived

    AddHandler Msgr.OnUnreadEmailChanged, AddressOf Me.OnUnreadEmailChanged

    AddHandler Msgr.OnUserStateChanged, AddressOf Me.OnUserStateChanged
    End Sub 'Form1_Load


    'The TextReceived Event
    Private Sub OnTextReceived(Session As IMsgrIMSession, User As IMsgrUser, Header As String, MsgText As String, ByRef Enabled As Boolean)
    'Simply write this info to the textbox
    textBox1.Text += User.ToString() + " " + Header.ToString()
    textBox1.Text += " " + MsgText.ToString()
    End Sub 'OnTextReceived


    'The OnUnreadEmailChanged event
    Private Sub OnUnreadEmailChanged(Folder As Interop.Messenger.MFOLDER, UnReadEmails As Integer, ByRef Enabled As Boolean)
    'Simply write this info to the textbox
    textBox1.Text += "MFOLDER " + Folder.ToString()
    textBox1.Text += "a " + UnReadEmails.ToString()
    End Sub 'OnUnreadEmailChanged


    'The OnUserStateChanged event
    Private Sub OnUserStateChanged(User As Interop.Messenger.IMsgrUser, PreviousState As Interop.Messenger.MSTATE, ByRef Enabled As Boolean)
    'Again simply write this info to the textbox
    textBox1.Text += User.FriendlyName + "'s state has changed to " + User.State

    textBox1.Text += User.FriendlyName + "'s previous state was " + PreviousState
    End Sub 'OnUserStateChanged

    Sadly I can make no guarantees as to if this code would actually work as advertised however it is a more or less accurate conversion from the original C# code.



  • Blipwort

    Can someone please help

  • VernonRhoda

    When I am typing                 Dim Msgr As New MsgrObjectClass()                       a blue line appears under MsgrObjectClass and it says that this type is not defined. Do I have to do something before this code like a dll or something else
    Thanks

  • thisiswhere

    you need to add a reference to the messenger dll in the program files\msn messenger directory. the file is called MessengerClient.dll

    In vb it is under tools/references.



  • satsrinivasan

    I would suggest taking a look at the C# based example here for some ideas.

  • bw12117

    I cannot understand what you have to do before the program. I cannot understand those steps that are shown in the website. Please Help.

  • MatteusX

    But I would like a step by step example of visual basic.net not C#.

  • Shaantu

    GlennZarb wrote:
    Do I have to do something before this code like a dll or something else

    Take a look at the article I linked you to previously and follow the steps there and use the code I gave you in my last post in place of the C# code in the article.



  • MSN Messeger