Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Copy folder
The following example shows you how to copy 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 { FolderId backupFolderId = service.CreateFolder("Backup", StandardFolder.MailboxRoot); FindFolderResponse findFolderResponse = service.FindFolder(StandardFolder.Drafts); for (int i = 0; i < findFolderResponse.Folders.Count; i++) { FolderId currentFolderId = findFolderResponse.Folders[i].FolderId; FolderId newFolderId = service.CopyFolder(currentFolderId, backupFolderId); } } 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 backupFolderId As FolderId = service.CreateFolder("Backup", StandardFolder.MailboxRoot) Dim findFolderResponse As FindFolderResponse = service.FindFolder(StandardFolder.Drafts) For i As Integer = 0 To findFolderResponse.Folders.Count - 1 Dim currentFolderId As FolderId = findFolderResponse.Folders(i).FolderId Dim newFolderId As FolderId = service.CopyFolder(currentFolderId, backupFolderId) Next 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*