Hawkeye111
Hawkeye111

Reputation: 37

How do I send a Skype message to multiple contacts in a list from a textbox?

I would like to know how to send a Skype message to multiple contacts at a time. For example, the textbox contains this:

  1. user1
  2. user2
  3. user3

Right now, to send a message to a specific contact I use:

Skypattach.SendMessage("username", "message")

So instead of having to do

Skypattach.SendMessage("username1", "message")
Skypattach.SendMessage("username2", "message")
Skypattach.SendMessage("username3", "message")

I would like it to be quicker, to grab the usernames from a textbox. Thanks for your time.

Upvotes: 1

Views: 1867

Answers (1)

Mark Hall
Mark Hall

Reputation: 54562

To flesh out my comment, the TextBox control has a Lines Property which you can iterate through to get each individual line. So if your text looks exactly like what your question shows, you can use something like this. Notice that I am splitting on the period, you can use the space or what ever delineator you decide on.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    SendSkype(TextBox1.Lines)
End Sub

Private Sub SendSkype(rawUserNameData As String())
    Dim x As Integer
    Dim receipients() As String
    If rawUserNameData.Count > 0 Then
        ReDim receipients(rawUserNameData.Count - 1)
        For x = 0 To rawUserNameData.Count - 1
            Try

                receipients(x) = Trim(Split(rawUserNameData(x), ".")(1))

            Catch ex As IndexOutOfRangeException 'Catch Unproperly formatted entries
            End Try
        Next
        For Each s As String In receipients
            Skypattach.SendMessage(s, "Message")
        Next
    End If
End Sub

Upvotes: 2

Related Questions