Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET for Exchange
>
Tutorial
> Authentication
The following examples shows you how to use different authentication types.
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) { //Basic or Digest authentication NetworkCredential credential = new NetworkCredential("username", "password"); //Windows Integrated Authentication //ICredentials credential = CredentialCache.DefaultCredentials; WebdavSession session = new WebdavSession(credential); session.UserMailbox = "https://myserver/exchange/emailaddress"; Resource resource = new Resource(session); Appointment appointment1 = new Appointment(); appointment1.Subject = "appointment1"; appointment1.Body = "Here is a body text."; appointment1.StartDate = DateTime.Now; appointment1.EndDate = DateTime.Now.AddHours(2); appointment1.IsRecurring = false; appointment1.MeetingStatus = MeetingStatus.Tentative; MultiStatus multiStatus = resource.CreateItem(appointment1); string appointmentUrl = multiStatus.Response[0].HRef; Console.WriteLine("Url of just created appointment = " + appointmentUrl); 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) 'Basic or Digest authentication Dim credential As NetworkCredential = New NetworkCredential("username", "password") 'Windows Integrated authentication 'Dim credential As ICredentials = CredentialCache.DefaultCredentials Dim session As WebdavSession = New WebdavSession(credential) session.UserMailbox = "https://myserver/exchange/emailaddress" Dim resource As Resource = New Resource(session) Dim appointment1 As Appointment = New Appointment appointment1.Subject = "appointment1" appointment1.Body = "Here is a body text." appointment1.StartDate = DateTime.Now appointment1.EndDate = DateTime.Now.AddHours(2) appointment1.IsRecurring = False appointment1.MeetingStatus = MeetingStatus.Tentative Dim multiStatus As MultiStatus = resource.CreateItem(appointment1) Dim appointmentUrl As String = multiStatus.Response(0).HRef Console.WriteLine("Url of just created appointment = " & appointmentUrl) Console.WriteLine("Press ENTER to exit") Console.Read() End Sub End Module