This tutorial demonstrates how to import and export MindFusion.Scheduling event information from/to MS Outlook.
Follow steps 1 through 3 from Tutorial 1: Getting Started.
Set CurrentView to WeekRange, Date to Jan 1, 2006 and EndDate to Mar 1, 2006, respectively.
Go to the 'Solution Explorer' window. You can show this window by selecting View -> Solution Explorer from the menu. Find the 'References' node in the tree view displayed in the 'Solution Explorer', right-click on it with the mouse and select 'Add Reference...' from the context menu that appears. In the "Add reference" dialog click the 'Browse...' button and navigate to the Outlook Import/Export library - MindFusion.Scheduling.Outlook.dll. This file is usually found in the 'c:\Program Files\MindFusion\MindFusion.Scheduling for WinForms' folder or in the folder where you have installed the product. Click the 'OK' button to add the assembly reference to your project.
Include the MindFusion.Scheduling and MindFusion.Scheduling.Outlook namespaces in the beginning of the file. These namespaces contain all schedule classes along with the OutlookImporter and OutlookExporter classes, which provide Outlook Export/Import capabilities.
C# Copy Code |
---|
using MindFusion.Scheduling; |
Visual Basic Copy Code |
---|
Imports MindFusion.Scheduling |
Add two buttons to the form, named _btnImport and _btnExport accordingly. Set the texts of the buttons to 'Import' and 'Export' respectively. Create a Click event handler for each of those buttons by double-clicking on the buttons in the design environment.
The body of the event handler of the 'Import' button should look like this:
C# Copy Code |
---|
private void _btnImport_Click(object sender, System.EventArgs e) |
Visual Basic Copy Code |
---|
Private Sub _btnImport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles _btnImport.Click |
The code above creates a new instance of the OutlookImporter class, passing to the constructor a reference to the Schedule object, which will be the target of the importing operation. Then it calls the ImportItems method of the OutlookImporter class in order to import all items from Outlook to the specified schedule. More complicated scenarios are possible. For example you can filter certain items during the importing process by attaching a handler to the ItemImporting event of the OutlookImporter class.
The body of the event handler of the 'Export' button will look similarly.
C# Copy Code |
---|
private void _btnExport_Click(object sender, System.EventArgs e) |
Visual Basic Copy Code |
---|
Private Sub _btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles _btnExport.Click |
Compile and run the application. Click the 'Import' button to import all items from Outlook into out application. Click the 'Export' button to export all items from the application to Outlook.