如何创建仲裁聊天,然后在创建的聊天中添加联系人

时间:2016-05-06 03:16:11

标签: .net vb.net skype4com

如标题所示,我正在尝试创建一个主持聊天,然后在创建的聊天中添加联系人。

我尝试将此人添加到群组聊天中(类似这样):

For Each chat As Chat In Skypattach.BookmarkedChats
If chat.Name = "#my-skype/$baf1ad******" Then
    msg.Chat.SendMessage("Please wait while we add you!)
    chat.SendMessage("/add " & "contact-to-add")
End If
Next

但是我需要指定聊天名称,所以现在不行。我有一个想法,我不知道该怎么做,不知道是否可能,还有一种方法来创建主持聊天,然后获取聊天的聊天名称创建?这可以解决我的问题...如果我的问题得到解决,请告诉我。谢谢你的时间。

1 个答案:

答案 0 :(得分:1)

我很惊讶线chat.SendMessage("/add " & "contact-to-add")首先起作用,因为我在使用它时会出错。因此,我使用子程序通过UserCollection对象添加新成员。如果要添加新成员,请添加到UserCollection,然后将其传递给AddMembers()子例程。

至于聊天名称本身,你不需要它。如果您在现场创建聊天,则将其分配给聊天变量。

Imports SKYPE4COMLib


Public Class Form1

Dim skype As Skype
Dim uc As UserCollection
Dim chat As Chat

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    skype = New Skype()
    skype.Attach(7, True)
End Sub


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    uc = New UserCollection()    'Hold the users in a UserCollection obj
    uc.Add(skype.User("echo123"))
    uc.Add(skype.User("otherperson_123123123123121625"))

    chat = skype.CreateChatMultiple(uc)  'Create the chat with the 2 users
    chat.OpenWindow()
    chat.Topic = "test"
    chat.SendMessage("test")
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    'CHECK TO MAKE SURE YOU DON'T TRY AND ADD SAME PERSON TWICE!
    'For some reason, attempting to do so causes errors.
    For Each r As User In uc
        If TextBox1.Text = r.Handle Then
            Return
        End If
    Next
    skype.SendMessage(TextBox1.Text, "Please wait while we add you!")
    uc.Add(skype.User(TextBox1.Text))
    chat.AddMembers(uc)
End Sub
End Class

我希望你能回答你的问题并对你有用。