Dear All,
I ran the following c# code on the machine running exchange server 2003. The applications seems okey as no exception is generated and I just can not see any appointment item is created in both exchange server and outlook.
Code in CreateAppointment()is copied directly from Exchange Server 2003 SDK.
Person iPerson; IMailbox iMailbox; public static CDO.Appointment CreateAppointment(DateTime StartTime,DateTime EndTime,String Subject,String Location,
String TextBody,
CDO.IMailbox iMbx)
{
try
{
// Variables.CDO.
Appointment iAppt = new CDO.Appointment();ADODB.
Connection Conn = new ADODB.Connection();Conn.Provider =
"ExOLEDB.DataSource"; //Set the appointment properties.iAppt.StartTime = StartTime;
iAppt.EndTime = EndTime;
iAppt.Subject = Subject;
iAppt.Location = Location;
iAppt.TextBody = TextBody;
//Save the appointmentConn.Open(iMbx.BaseFolder,
"", "", -1);iAppt.DataSource.SaveToContainer(iMbx.Calendar, Conn,
ADODB.
ConnectModeEnum.adModeReadWrite,ADODB.
RecordCreateOptionsEnum.adCreateNonCollection,ADODB.
RecordOpenOptionsEnum.adOpenSource, "", ""); Console.WriteLine("Appointment saved."); return iAppt;}
catch (Exception err){
Console.WriteLine(err.ToString()); return null;}
}
private void btnCreate_Click(object sender, EventArgs e){
try{
string strEmail = "MAILTO:" + this.txtOrganizerEmail.Text;iPerson =
new PersonClass();iPerson.DataSource.Open(strEmail,
null,ADODB.
ConnectModeEnum.adModeRead,ADODB.
RecordCreateOptionsEnum.adFailIfNotExists,ADODB.
RecordOpenOptionsEnum.adOpenSource, String.Empty, String.Empty);
iMailbox = (
IMailbox)iPerson.GetInterface("IMailbox"); DateTime curDateTime = DateTime.Now;CreateAppointment(curDateTime, curDateTime.AddHours(2.0),
"AAA", "Location", "hahahah", iMailbox); MessageBox.Show("Created");}
catch (Exception ex){
MessageBox.Show(ex.ToString());}
}
Please help
Thanks