Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Get folder
The following example shows you how to retrieve 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 { //Get all folder properties Folder inboxFolder1 = service.GetFolder(StandardFolder.Inbox); //Get only FolderId property of the Inbox folder Folder inboxFolder2 = service.GetFolder(StandardFolder.Inbox, ShapeType.Id); PropertyPathCollection propertyPaths = new PropertyPathCollection(); propertyPaths.Add(FolderPropertyPath.DisplayName); propertyPaths.Add(FolderPropertyPath.FolderClass); propertyPaths.Add(FolderPropertyPath.Comment); //Get specified properties Folder inboxFolder3 = service.GetFolder(StandardFolder.Inbox, propertyPaths); } 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 'Get all folder properties Dim inboxFolder1 As Folder = service.GetFolder(StandardFolder.Inbox) 'Get only FolderId property of the Inbox folder Dim inboxFolder2 As Folder = service.GetFolder(StandardFolder.Inbox, ShapeType.Id) Dim propertyPaths As New PropertyPathCollection() propertyPaths.Add(FolderPropertyPath.DisplayName) propertyPaths.Add(FolderPropertyPath.FolderClass) propertyPaths.Add(FolderPropertyPath.Comment) 'Get specified properties Dim inboxFolder3 As Folder = service.GetFolder(StandardFolder.Inbox, propertyPaths) 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