Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Create folder
The following example shows you how to create a folder.
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 { Folder folder1 = new Folder("Test1"); Folder folder2 = new Folder("Test2"); //Create a folder in the mailbox root FolderId folder1Id = service.CreateFolder(folder1, StandardFolder.MailboxRoot); //Create a subfolder of the Test1 FolderId folder2Id = service.CreateFolder(folder2, folder1Id); } 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 folder1 As New Folder("Test1") Dim folder2 As New Folder("Test2") 'Create a folder in the mailbox root Dim folder1Id As FolderId = service.CreateFolder(folder1, StandardFolder.MailboxRoot) 'Create a subfolder of the Test1 Dim folder2Id As FolderId = service.CreateFolder(folder2, folder1Id) 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*