Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Get out of office
The following example shows you how to get Out of Office status.
C# example
using System; using System.Net; using Independentsoft.Exchange; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "passsword"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { OutOfOfficeResponse response = service.GetOutOfOffice("John@mydomain.com"); OutOfOffice oof = response.OutOfOffice; Console.WriteLine("State = " + oof.State); if (oof.InternalReply != null) { Console.WriteLine("InternalReply = " + oof.InternalReply.Message); } if (oof.ExternalReply != null) { Console.WriteLine("ExternalReply = " + oof.ExternalReply.Message); } 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 response As OutOfOfficeResponse = service.GetOutOfOffice("John@mydomain.com") Dim oof As OutOfOffice = response.OutOfOffice Console.WriteLine("State = " & oof.State.ToString()) If oof.InternalReply IsNot Nothing Then Console.WriteLine("InternalReply = " & oof.InternalReply.Message) End If If oof.ExternalReply IsNot Nothing Then Console.WriteLine("ExternalReply = " & oof.ExternalReply.Message) End If 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*