Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Update folder
The following example shows you how to set folder properties.
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 { PropertyName myCustomPropertyName = new PropertyName("myproperty", StandardPropertySet.PublicStrings, MapiPropertyType.String); Property myCustomProperty = new Property(myCustomPropertyName, "value1"); Property commentProperty = new Property(FolderPropertyPath.Comment, "Folder description text."); //Get only FolderId property of the Inbox folder Folder inboxFolder = service.GetFolder(StandardFolder.Inbox, ShapeType.Id); FolderId newFolderId1 = service.UpdateFolder(inboxFolder.FolderId, myCustomProperty); FolderId newFolderId2 = service.UpdateFolder(inboxFolder.FolderId, commentProperty); } 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 myCustomPropertyName As New PropertyName("myproperty", StandardPropertySet.PublicStrings, MapiPropertyType.[String]) Dim myCustomProperty As New [Property](myCustomPropertyName, "value1") Dim commentProperty As New [Property](FolderPropertyPath.Comment, "Folder description text.") 'Get only FolderId property of the Inbox folder Dim inboxFolder As Folder = service.GetFolder(StandardFolder.Inbox, ShapeType.Id) Dim newFolderId1 As FolderId = service.UpdateFolder(inboxFolder.FolderId, myCustomProperty) Dim newFolderId2 As FolderId = service.UpdateFolder(inboxFolder.FolderId, commentProperty) 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*