Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Create folder path
The following example shows you how to create folder with subfolders.
C# example
using System; using System.Net; using System.Collections.Generic; 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); //works on Exchange 2013 / Office365 and higher service.RequestServerVersion = RequestServerVersion.Exchange2013; try { IList
subfolders = new List
(); subfolders.Add(new Folder("Folder1")); //Folder1 is under Inbox folder subfolders.Add(new Folder("Folder2")); //Folder2 is under Folder1 subfolders.Add(new Folder("Folder3")); //Folder3 is under Folder2 IList
response = service.CreateFolderPath(subfolders, StandardFolder.Inbox); } 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 System.Collections.Generic 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) ''works on Exchange 2013 / Office365 and higher service.RequestServerVersion = RequestServerVersion.Exchange2013 Try Dim subfolders As IList(Of Folder) = New List(Of Folder)() subfolders.Add(New Folder("Folder1")) ''Folder1 is under Inbox folder subfolders.Add(New Folder("Folder2")) ''Folder2 is under Folder1 subfolders.Add(New Folder("Folder3")) ''Folder3 is under Folder2 Dim response As IList(Of FolderInfoResponse) = service.CreateFolderPath(subfolders, StandardFolder.Inbox) 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*