Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Create appointment (event)
The following example shows you how to create an appointment (event).
C# example
using System; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Users; using Independentsoft.Graph.Calendars; namespace Sample { class Program { static async Task Main(string[] args) { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; Event appointment = new Event(); appointment.Subject = "Development meeting"; appointment.Body = new ItemBody("Body text can be html or plain text. We set it now as a plain text.", ContentType.Text); appointment.Start = new DateTimeTimeZone(DateTime.Today.AddHours(16), "Pacific Standard Time"); appointment.End = new DateTimeTimeZone(DateTime.Today.AddHours(17), "Pacific Standard Time"); Location location = new Location(); location.DisplayName = "Office 123"; location.Type = LocationType.ConferenceRoom; appointment.Location = location; Event createdAppointment = await client.CreateEvent(appointment, new UserId("info@independentsoft.onmicrosoft.com")); Console.WriteLine("Id = " + createdAppointment.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.Users Imports Independentsoft.Graph.Calendars 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.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Dim appointment As [Event] = New [Event]() appointment.Subject = "Development meeting" appointment.Body = New ItemBody("Body text can be html or plain text. We set it now as a plain text.", ContentType.Text) appointment.Start = New DateTimeTimeZone(DateTime.Today.AddHours(16), "Pacific Standard Time") appointment.[End] = New DateTimeTimeZone(DateTime.Today.AddHours(17), "Pacific Standard Time") Dim location As Location = New Location() location.DisplayName = "Office 123" location.Type = LocationType.ConferenceRoom appointment.Location = location Dim createdAppointment As [Event] = Await client.CreateEvent(appointment, New UserId("info@independentsoft.onmicrosoft.com")) Console.WriteLine("Id = " & createdAppointment.Id) 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*