using System;
namespace Samples
{
class Class1
{
static void Main(string[] args)
{
try
{
CDO.Appointment oApp = new CDO.Appointment();
// TODO: Replace with your folder URL
string sURL = "http://ExchServer/Exchange/UserAlias/calendar";
ADODB.Connection oCn = new ADODB.Connection();
oCn.Provider = "exoledb.datasource";
oCn.Open(sURL, "", "", 0);
if(oCn.State == 1)
{
Console.WriteLine("Good Connection");
}
else
{
Console.WriteLine("Bad Connection");
}
CDO.Configuration iConfg = new CDO.Configuration();
ADODB.Fields oFields;
oFields = iConfg.Fields;
oFields[CDO.CdoCalendar.cdoTimeZoneIDURN].Value = CDO.CdoTimeZoneId.cdoPacific;
oFields.Update();
oApp.Configuration = iConfg;
oApp.StartTime = Convert.ToDateTime("10/11/2001 10:00:00 AM");
oApp.EndTime = Convert.ToDateTime("10/11/2001 11:00:00 AM");
oApp.Location = "My Cube";
oApp.Subject = "Test Create App in C#";
oApp.TextBody = "Hello...";
// Add Recurring
// Every Thursday starting Today and run 3 times
CDO.IRecurrencePatterns iRPatters = oApp.RecurrencePatterns;
CDO.IRecurrencePattern iRPatter = iRPatters.Add("Add");
iRPatter.Frequency = CDO.CdoFrequency.cdoWeekly;
iRPatter.Interval = 1; // 1 hour from 10 to 11
iRPatter.DaysOfWeek.Add(4); // every Thursday
iRPatter.Instances = 3;
// Specify Exceptions
CDO.IExceptions iExceps = oApp.Exceptions;
CDO.IException iExcep;
// Delete
iExcep = oApp.Exceptions.Add("DELETE");
iExcep.RecurrenceID = Convert.ToDateTime("10/11/2001 10:00:00 AM");
// Modify
iExcep = oApp.Exceptions.Add("MODIFY");
iExcep.RecurrenceID = Convert.ToDateTime("10/18/2001 10:00:00 AM");
iExcep.StartTime = Convert.ToDateTime("10/17/2001 10:00:00 AM");
iExcep.EndTime = Convert.ToDateTime("10/17/2001 1:00:00 pM");
oApp.DataSource.SaveToContainer(sURL, null,
ADODB.ConnectModeEnum.adModeReadWrite,
ADODB.RecordCreateOptionsEnum.adCreateNonCollection,
ADODB.RecordOpenOptionsEnum.adOpenSource,
"", "");
oCn.Close();
oApp = null;
oCn = null;
oFields = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}
}