Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Update meeting - Add attendee
The following example shows you how to add an attendee to existing meeting and send meeting update.
C# example
using System; using System.Net; 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 { Contains restriction = new Contains(MessagePropertyPath.Subject, "test", ContainmentMode.ExactPhrase, ContainmentComparison.IgnoreCase); FindItemResponse response = service.FindItem(StandardFolder.Calendar, restriction); for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i] is Appointment) { Property requiredAttendees = new Property(AppointmentPropertyPath.RequiredAttendees, new Attendee("John@mydomain.com")); ItemChange itemChange = new ItemChange(); itemChange.ItemId = response.Items[i].ItemId; itemChange.PropertiesToAppend.Add(requiredAttendees); ItemId newItemId = service.UpdateItem(itemChange, SendMeetingOption.SendToAll); } } } 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 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 restriction As New Contains(MessagePropertyPath.Subject, "test", ContainmentMode.ExactPhrase, ContainmentComparison.IgnoreCase) Dim response As FindItemResponse = service.FindItem(StandardFolder.Calendar, restriction) For i As Integer = 0 To response.Items.Count - 1 If TypeOf response.Items(i) Is Appointment Then Dim requiredAttendees As New [Property](AppointmentPropertyPath.RequiredAttendees, New Attendee("John@mydomain.com")) Dim itemChange As New ItemChange() itemChange.ItemId = response.Items(i).ItemId itemChange.PropertiesToAppend.Add(requiredAttendees) Dim newItemId As ItemId = service.UpdateItem(itemChange, SendMeetingOption.SendToAll) 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