Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Update appointment
The following example shows you how to update an apppointment.
C# example
using System; using System.Net; using System.Collections.Generic; using Independentsoft.Exchange; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { IsEqualTo restriction1 = new IsEqualTo(AppointmentPropertyPath.StartTime, DateTime.Today.AddHours(15)); IsEqualTo restriction2 = new IsEqualTo(AppointmentPropertyPath.EndTime, DateTime.Today.AddHours(16)); And restriction3 = new And(restriction1, restriction2); FindItemResponse response = service.FindItem(StandardFolder.Calendar, restriction3); for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i] is Appointment) { ItemId itemId = response.Items[i].ItemId; Property startTimeProperty = new Property(AppointmentPropertyPath.StartTime, DateTime.Today.AddHours(18)); Property endTimeProperty = new Property(AppointmentPropertyPath.EndTime, DateTime.Today.AddHours(19)); IList
properties = new List
(); properties.Add(startTimeProperty); properties.Add(endTimeProperty); itemId = service.UpdateItem(itemId, properties); } } } catch (ServiceRequestException ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error: " + ex.XmlMessage); Console.Read(); } catch (WebException ex) { Console.WriteLine("Error: " + ex.Message); Console.Read(); } } } }
VB example
Imports System Imports System.Net Imports System.Collections.Generic Imports Independentsoft.Exchange Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim credential As New NetworkCredential("username", "password") Dim service As New Service("https://myserver/ews/Exchange.asmx", credential) Try Dim restriction1 As New IsEqualTo(AppointmentPropertyPath.StartTime, DateTime.Today.AddHours(15)) Dim restriction2 As New IsEqualTo(AppointmentPropertyPath.EndTime, DateTime.Today.AddHours(16)) Dim restriction3 As New [And](restriction1, restriction2) Dim response As FindItemResponse = service.FindItem(StandardFolder.Calendar, restriction3) For i As Integer = 0 To response.Items.Count - 1 If TypeOf response.Items(i) Is Appointment Then Dim itemId As ItemId = response.Items(i).ItemId Dim startTimeProperty As New [Property](AppointmentPropertyPath.StartTime, DateTime.Today.AddHours(18)) Dim endTimeProperty As New [Property](AppointmentPropertyPath.EndTime, DateTime.Today.AddHours(19)) Dim properties As New List(Of [Property])() properties.Add(startTimeProperty) properties.Add(endTimeProperty) itemId = service.UpdateItem(itemId, properties) End If Next Catch ex As ServiceRequestException Console.WriteLine("Error: " + ex.Message) Console.WriteLine("Error: " + ex.XmlMessage) Console.Read() Catch ex As WebException Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*