how to get data from meeting in outlook calendar

  • Thread starter Thread starter Diya Bsharat
  • Start date Start date
D

Diya Bsharat

Guest
I have This code below ,and I need to get meeting data from another calendar at my outlook



using System;
using System.Reflection;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace RetrieveAppointment
{
public class Class1
{

public static int Main(string[] args)
{
try
{
// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();

// Get the NameSpace and Logon information.
// Outlook.NameSpace oNS = (Outlook.NameSpace)oApp.GetNamespace("mapi");
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

//Log on by using a dialog box to choose the profile.
oNS.Logon(Missing.Value, Missing.Value, true, true);

//Alternate logon method that uses a specific profile.
// TODO: If you use this logon method,
// change the profile name to an appropriate value.
//oNS.Logon("YourValidProfile", Missing.Value, false, true);

// Get the Calendar folder.
Outlook.MAPIFolder oCalendar = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

// Get the Items (Appointments) collection from the Calendar folder.
Outlook.Items oItems = oCalendar.Items;

// Get the first item.
LinkedList l = new LinkedList();
for (int i = -1; i <= oCalendar.Items.Count; i++)
{
Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)oItems.GetNext();

// Outlook.MeetingItem mee = (Outlook.MeetingItem)oItems.GetNext();
// Show some common properties.
Console.WriteLine("Subject: " + oAppt.Subject);
Console.WriteLine("Organizer: " + oAppt.Organizer);
Console.WriteLine("Start: " + oAppt.Start.ToString());
Console.WriteLine("End: " + oAppt.End.ToString());
Console.WriteLine("Location: " + oAppt.Location);
Console.WriteLine("Recurring: " + oAppt.IsRecurring);
Console.ReadLine();
// string saveStaff = "INSERT into db_accessadmin.Events ([Start_Date_Time],[End_Date_Time],[Organizer] ,[Description]) " +
// " VALUES ('" + oAppt.Start.ToString() + "', '" + oAppt.End.ToString() + "', '" + oAppt.Organizer + "', '" + oAppt.Subject + "');";


//Show the item to pause.
// oAppt.Display();

}
// Done. Log off.
oNS.Logoff();

// Clean up.
//oAppt = null;
oItems = null;
oCalendar = null;
oNS = null;
oApp = null;

Console.ReadLine();
Console.ReadLine();
}

//Simple error handling.
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}

//Default return value
return 0;

}
}
public class Node
{
public Node next;
public Object data;
}

public class LinkedList
{
private Node head;

public void printAllNodes()
{
Node current = head;
while (current != null)
{
Console.WriteLine(current.data);
current = current.next;
}
}

public void AddFirst(Object data)
{
Node toAdd = new Node();

toAdd.data = data;
toAdd.next = head;

head = toAdd;
}
}
}

Continue reading...
 
Back
Top