Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET for Exchange
>
Tutorial
> Create task inside another user's mailbox
The following example shows you how to create task inside another user's mailbox.
C# example
using System; using System.Net; using Independentsoft.Webdav.Exchange; using Independentsoft.Webdav.Exchange.ContentClass; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); WebdavSession session = new WebdavSession(credential); session.UserMailbox = "https://myserver/exchange/emailaddress"; Resource resource = new Resource(session); Mailbox johnMailbox = resource.GetMailbox("https://myserver/exchange/John@mydomain.com"); DateTime startDate = DateTime.Today; DateTime endDate = DateTime.Today.AddDays(5); Task task1 = new Task(); task1.Subject = "task1"; task1.StartDate = startDate; task1.CommonStart = startDate; task1.DueDate = endDate; task1.CommonEnd = endDate; task1.Body = "Body text"; MultiStatus multiStatus = resource.CreateItem(johnMailbox, task1); string taskUrl = multiStatus.Response[0].HRef; Console.WriteLine("Url of just created task = " + taskUrl); Console.WriteLine("Press ENTER to exit"); Console.Read(); } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Webdav.Exchange Imports Independentsoft.Webdav.Exchange.ContentClass Module Module1 Sub Main(ByVal args() As String) Dim credential As NetworkCredential = New NetworkCredential("username", "password") Dim session As WebdavSession = New WebdavSession(credential) session.UserMailbox = "https://myserver/exchange/emailaddress" Dim resource As Resource = New Resource(session) Dim johnMailbox As Mailbox = resource.GetMailbox("https://myserver/exchange/John@mydomain.com") Dim startDate As DateTime = DateTime.Today Dim endDate As DateTime = DateTime.Today.AddDays(5) Dim task1 As Task = New Task task1.Subject = "task1" task1.StartDate = startDate task1.CommonStart = startDate task1.DueDate = endDate task1.CommonEnd = endDate task1.Body = "Body text" Dim multiStatus As MultiStatus = resource.CreateItem(johnMailbox, task1) Dim taskUrl As String = multiStatus.Response(0).HRef Console.WriteLine("Url of just created task = " & taskUrl) Console.WriteLine("Press ENTER to exit") Console.Read() End Sub End Module