Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET for Exchange
>
Tutorial
> Create item with custom properties
The following example shows you how to create an appointment and set custom properties.
C# example
using System; using System.Net; using Independentsoft.Webdav.Exchange; using Independentsoft.Webdav.Exchange.ContentClass; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); WebdavSession session = new WebdavSession(credential); session.UserMailbox = "https://myserver/exchange/emailaddress"; Resource resource = new Resource(session); Appointment appointment1 = new Appointment(); appointment1.Subject = "appointment1"; appointment1.Body = "Here is a body text."; appointment1.StartDate = DateTime.Now; appointment1.EndDate = DateTime.Now.AddHours(2); appointment1.MeetingStatus = MeetingStatus.Tentative; Property[] myProperties = new Property[3]; myProperties[0] = new Property("city", "address:", "Berlin"); myProperties[1] = new Property("street", "address:", "One Street."); myProperties[2] = new Property("number", "address:", "10"); MultiStatus multiStatus = resource.CreateItem(appointment1, myProperties); string appointmentUrl = multiStatus.Response[0].HRef; Console.WriteLine("Url of just created appointment = " + appointmentUrl); Console.WriteLine("Press ENTER to exit"); Console.Read(); } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Webdav.Exchange Imports Independentsoft.Webdav.Exchange.ContentClass Module Module1 Sub Main(ByVal args() As String) Dim credential As NetworkCredential = New NetworkCredential("username", "password") Dim session As WebdavSession = New WebdavSession(credential) session.UserMailbox = "https://myserver/exchange/emailaddress" Dim resource As Resource = New Resource(session) Dim appointment1 As Appointment = New Appointment appointment1.Subject = "appointment1" appointment1.Body = "Here is a body text." appointment1.StartDate = DateTime.Now appointment1.EndDate = DateTime.Now.AddHours(2) appointment1.MeetingStatus = MeetingStatus.Tentative Dim myProperties() As Independentsoft.Webdav.Exchange.Property = New Independentsoft.Webdav.Exchange.Property(2) {} myProperties(0) = New Independentsoft.Webdav.Exchange.Property("city", "address:", "Berlin") myProperties(1) = New Independentsoft.Webdav.Exchange.Property("street", "address:", "One Street.") myProperties(2) = New Independentsoft.Webdav.Exchange.Property("number", "address:", "10") Dim multiStatus As MultiStatus = resource.CreateItem(appointment1, myProperties) Dim appointmentUrl As String = multiStatus.Response(0).HRef Console.WriteLine("Url of just created appointment = " & appointmentUrl) Console.WriteLine("Press ENTER to exit") Console.Read() End Sub End Module