using System;
namespace Samples
{
class Class1
{
static void Main(string[] args)
{
try
{
CDO.Appointment oApp = new CDO.Appointment();
// TODO: Replace the Exchange server name and UserAlias with your own.
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("Connection Successful");
}
else
{
Console.WriteLine("Connection Failed");
}
CDO.Configuration iConfg = new CDO.Configuration();
ADODB.Fields oFields;
oFields = iConfg.Fields;
oFields[CDO.CdoCalendar.cdoTimeZoneIDURN].Value = CDO.CdoTimeZoneId.cdoPacific;
// Set Meeting Organizer.
// TODO: Change the e-mail address to your own e-mail address.
oFields[CDO.CdoConfiguration.cdoSendEmailAddress].Value = "someone@example.net";
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 = "Office";
oApp.Subject = "Test: Create Meeting in C#";
oApp.TextBody = "Message body of test message...";
// Add the New Recurring Meeting
// every Thursday, starting today, and then run three 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");
// Add attendees.
// TODO: Change e-mail address to your own attendee.
CDO.IAttendees iAtdees = oApp.Attendees;
CDO.IAttendee iAtdee = iAtdees.Add("someone@example.net");
CDO.ICalendarMessage iCalMsg = (CDO.ICalendarMessage)oApp.CreateRequest();
iCalMsg.Message.Send();
// Save to the Events Calendar.
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);
}
}
}
}