Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
PST .NET
>
Tutorial
> Get appointments
The following example shows you how to get all appointments from the Calendar folder.
C# example
using System; using Independentsoft.Pst; namespace Sample { class Program { static void Main(string[] args) { PstFile file = new PstFile("c:\\testfolder\\Outlook.pst"); using (file) { Folder calendar = file.MailboxRoot.GetFolder("Calendar"); if (calendar != null) { ItemCollection items = calendar.GetItems(); for (int m = 0; m < items.Count; m++) { if (items[m] is Appointment) { Appointment appointment = (Appointment)items[m]; Console.WriteLine("Id: " + appointment.Id); Console.WriteLine("Subject: " + appointment.Subject); Console.WriteLine("StartTime: " + appointment.StartTime); Console.WriteLine("EndTime: " + appointment.EndTime); Console.WriteLine("----------------------------------------------------------------"); } } } } Console.WriteLine("Press ENTER to exit."); Console.Read(); } } }
VB example
Imports System Imports Independentsoft.Pst Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim file As New PstFile("c:\testfolder\Outlook.pst") Using file Dim calendar As Folder = file.MailboxRoot.GetFolder("Calendar") If calendar IsNot Nothing Then Dim items As ItemCollection = calendar.GetItems() For m As Integer = 0 To items.Count - 1 If TypeOf items(m) Is Appointment Then Dim appointment As Appointment = DirectCast(items(m), Appointment) Console.WriteLine("Id: " & appointment.Id) Console.WriteLine("Subject: " & appointment.Subject) Console.WriteLine("StartTime: " & appointment.StartTime) Console.WriteLine("EndTime: " & appointment.EndTime) Console.WriteLine("----------------------------------------------------------------") End If Next End If End Using Console.WriteLine("Press ENTER to exit.") Console.Read() End Sub End Class End Namespace