create Appointment on Exchange Server

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 appointment

Conn.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

December 11th, 2006 8:25pm

Hi..

Just go through the link. It may be helpful for you

https://msdn.microsoft.com/en-us/library/office/dd633661(v=exchg.80).aspx

Thanks

Joe


Free Windows Admin Tool Kit Click here and download it now
February 4th, 2015 4:40am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics