Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET for Exchange
>
Tutorial
> Set properties
The following example shows you how to set single property or array of properties.
C# example
using System; using System.Net; using Independentsoft.Webdav.Exchange; using Independentsoft.Webdav.Exchange.ContentClass; using Independentsoft.Webdav.Exchange.Properties; 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); string contactUrl = "https://myserver/exchange/emailaddress/Contacts/John.eml"; //Set contact's City property Property cityProperty = new Property(ContactProperty.City.Name, ContactProperty.City.Namespace, "Atlanta"); resource.SetProperty(contactUrl, cityProperty); //Set custom property Property myProperty = new Property("property1", "independentsoft:", "value1"); resource.SetProperty(contactUrl, myProperty); //Set array of properties Property[] propertyArray = new Property[5]; propertyArray[0] = new Property("property1", "mynamespace:", "value1"); propertyArray[1] = new Property("property2", "mynamespace:", "value2"); propertyArray[2] = new Property("property3", "mynamespace:", "value3"); propertyArray[3] = new Property("property4", "mynamespace:", "value4"); propertyArray[4] = new Property("property5", "mynamespace:", "value5"); resource.SetProperty(contactUrl, propertyArray); } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Webdav.Exchange Imports Independentsoft.Webdav.Exchange.ContentClass Imports Independentsoft.Webdav.Exchange.Properties 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 contactUrl As String = "https://myserver/exchange/emailaddress/Contacts/John.eml" 'Set contact's City property Dim cityProperty As Independentsoft.Webdav.Exchange.Property = New Independentsoft.Webdav.Exchange.Property(ContactProperty.City.Name, ContactProperty.City.Namespace, "Atlanta") resource.SetProperty(contactUrl, cityProperty) 'Set custom property Dim myProperty As Independentsoft.Webdav.Exchange.Property = New Independentsoft.Webdav.Exchange.Property("property1", "independentsoft:", "value1") resource.SetProperty(contactUrl, myProperty) 'Set array of properties Dim propertyArray() As Independentsoft.Webdav.Exchange.Property = New Independentsoft.Webdav.Exchange.Property(4) {} propertyArray(0) = New Independentsoft.Webdav.Exchange.Property("property1", "mynamespace:", "value1") propertyArray(1) = New Independentsoft.Webdav.Exchange.Property("property2", "mynamespace:", "value2") propertyArray(2) = New Independentsoft.Webdav.Exchange.Property("property3", "mynamespace:", "value3") propertyArray(3) = New Independentsoft.Webdav.Exchange.Property("property4", "mynamespace:", "value4") propertyArray(4) = New Independentsoft.Webdav.Exchange.Property("property5", "mynamespace:", "value5") resource.SetProperty(contactUrl, propertyArray) End Sub End Module