Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Set out of office
The following example shows you how to set 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", "password"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { OutOfOffice oof = new OutOfOffice(); oof.State = OutOfOfficeState.Scheduled; oof.Duration = new TimeDuration(DateTime.Today, DateTime.Today.AddDays(10)); oof.InternalReply = new ReplyBody("I am out of office until " + DateTime.Today.AddDays(10)); oof.ExternalReply = new ReplyBody("I am out of office until " + DateTime.Today.AddDays(10)); Response response = service.SetOutOfOffice(oof, "John@mydomain.com"); } 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 oof As New OutOfOffice() oof.State = OutOfOfficeState.Scheduled oof.Duration = New TimeDuration(DateTime.Today, DateTime.Today.AddDays(10)) oof.InternalReply = New ReplyBody("I am out of office until " + DateTime.Today.AddDays(10)) oof.ExternalReply = New ReplyBody("I am out of office until " + DateTime.Today.AddDays(10)) Dim response As Response = service.SetOutOfOffice(oof, "John@mydomain.com") 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*