Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Find folders by creation time
The following example shows you how to find folders created today.
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 { IsGreaterThanOrEqualTo restriction1 = new IsGreaterThanOrEqualTo(FolderPropertyPath.CreationTime, DateTime.Today); IsLessThan restriction2 = new IsLessThan(FolderPropertyPath.CreationTime, DateTime.Today.AddDays(1)); And restriction3 = new And(restriction1, restriction2); FindFolderResponse findFolderResponse = service.FindFolder(StandardFolder.MailboxRoot, FolderPropertyPath.AllPropertyPaths, restriction3, FolderQueryTraversal.Deep); for (int i = 0; i < findFolderResponse.Folders.Count; i++) { Console.WriteLine(findFolderResponse.Folders[i].DisplayName); Console.WriteLine(findFolderResponse.Folders[i].FolderClass); Console.WriteLine(findFolderResponse.Folders[i].CreationTime); Console.WriteLine(findFolderResponse.Folders[i].FolderId); Console.WriteLine("----------------------------------------------------------"); } Console.Read(); } 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 restriction1 As New IsGreaterThanOrEqualTo(FolderPropertyPath.CreationTime, DateTime.Today) Dim restriction2 As New IsLessThan(FolderPropertyPath.CreationTime, DateTime.Today.AddDays(1)) Dim restriction3 As New [And](restriction1, restriction2) Dim findFolderResponse As FindFolderResponse = service.FindFolder(StandardFolder.MailboxRoot, FolderPropertyPath.AllPropertyPaths, restriction3, FolderQueryTraversal.Deep) For i As Integer = 0 To findFolderResponse.Folders.Count - 1 Console.WriteLine(findFolderResponse.Folders(i).DisplayName) Console.WriteLine(findFolderResponse.Folders(i).FolderClass) Console.WriteLine(findFolderResponse.Folders(i).CreationTime) Console.WriteLine(findFolderResponse.Folders(i).FolderId) Console.WriteLine("----------------------------------------------------------") Next Console.Read() 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*