Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Create chat
The following example shows you how to create a new chat.
C# example
using System; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Teams; namespace ConsoleApp1 { class Program { static async Task Main() { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; ConversationMember member1 = new ConversationMember(); member1.DisplayName = "User1"; member1.UserId = "info@independentsoft.onmicrosoft.com"; member1.Roles.Add("owner"); ConversationMember member2 = new ConversationMember(); member2.DisplayName = "User2"; member2.UserId = "projects@independentsoft.onmicrosoft.com"; member2.Roles.Add("owner"); Chat chat = new Chat(); chat.Topic = "Test chat"; chat.Members.Add(member1); chat.Members.Add(member2); Chat createdChat = await client.CreateChat(chat); Console.WriteLine("Chat Id: " + createdChat.Id); Console.Read(); } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports Independentsoft.Graph Imports Independentsoft.Graph.Teams Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) ' Start and wait for task to end. task.Start() Console.Read() End Sub Shared Async Sub Run() Try Dim client As GraphClient = New GraphClient() client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f" client.Tenant = "independentsoft.onmicrosoft.com" client.Username = "info@independentsoft.onmicrosoft.com" client.Password = "password" Dim member1 As ConversationMember = New ConversationMember() member1.DisplayName = "User1" member1.UserId = "info@independentsoft.onmicrosoft.com" member1.Roles.Add("owner") Dim member2 As ConversationMember = New ConversationMember() member2.DisplayName = "User2" member2.UserId = "projects@independentsoft.onmicrosoft.com" member2.Roles.Add("owner") Dim chat As Chat = New Chat() chat.Topic = "Test chat" chat.Members.Add(member1) chat.Members.Add(member2) Dim createdChat As Chat = Await client.CreateChat(chat) Console.WriteLine("Chat Id: " & createdChat.Id) Console.Read() Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*