Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Create appointment in another mailbox
The following example shows you how to create an appointment in another user's mailbox.
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 { Mailbox johnMailbox = new Mailbox("John@mydomain.com"); StandardFolderId johnCalendarFolder = new StandardFolderId(StandardFolder.Calendar, johnMailbox); Appointment appointment = new Appointment(); appointment.Subject = "Test"; appointment.Body = new Body("Body text."); appointment.StartTime = DateTime.Today.AddHours(15); appointment.EndTime = DateTime.Today.AddHours(16); appointment.Location = "My Office"; appointment.ReminderIsSet = true; appointment.ReminderMinutesBeforeStart = 30; ItemId itemId = service.CreateItem(appointment, johnCalendarFolder); } 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 johnMailbox As New Mailbox("John@mydomain.com") Dim johnCalendarFolder As New StandardFolderId(StandardFolder.Calendar, johnMailbox) Dim appointment As New Appointment() appointment.Subject = "Test" appointment.Body = New Body("Body text.") appointment.StartTime = DateTime.Today.AddHours(10) appointment.EndTime = DateTime.Today.AddHours(12) appointment.Location = "My Office" appointment.ReminderIsSet = True appointment.ReminderMinutesBeforeStart = 30 Dim itemId As ItemId = service.CreateItem(appointment, johnCalendarFolder) 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