Iram
Hi Sue and thanks for your reply.
I read about the Find method and find it helpful, but:
I'm trying to catch conflicts between appointments before the user make any change.
What I'm doing is:
In the BeforeItemMove event I save the time of the appointment before the change
and in the ItemChange event I want to check if there any other appointment that occurs in this period of time.
I wrote this method like that:
private
void Items_ItemChange(object item)
{
object objAppointmentItem = null;
try
{
if (flagItemChange == true)//flagItemChange is a flag indicate that this event was raised after the BeforeItemMove event
{
Outlook.AppointmentItem ap = (Outlook.AppointmentItem)item;
if (globalAppointmentID != string.Empty)//globalAppointmentID is a variable that keep the GlobalAppointmentID that initialize in the BeforeItemMove event
{
if (globalAppointmentID.Equals(ap.GlobalAppointmentID))
{
string filter = "(('" + ap.Start.ToShortDateString() + " " + ap.Start.ToShortTimeString() + "'>[Start] And '" + ap.Start.ToShortDateString() + " " + ap.Start.ToShortTimeString() + "'<[End]) Or ('" + ap.End.ToShortDateString() + " " + ap.End.ToShortTimeString() + "'>[Start] And '" + ap.End.ToShortDateString() + " " + ap.End.ToShortTimeString() + "'<[End]) Or ('" + ap.Start.ToShortDateString() + " " + ap.Start.ToShortTimeString() + "'=[Start] And '" + ap.End.ToShortDateString() + " " + ap.End.ToShortTimeString() + "'=[End])) And ('" + ap.GlobalAppointmentID + "' <> [GlobalAppointmentID]) ";
objAppointmentItem = (Outlook.AppointmentItem)_sstFolder.Items.Find(filter);
if ((objAppointmentItem != null) && (((Outlook.AppointmentItem)objAppointmentItem).GlobalAppointmentID!=ap.GlobalAppointmentID))
{
ap.Start = start;
ap.End = end;
ap.Save();
}
}
globalAppointmentID = string.Empty;
}
}
}
catch (Exception ex)
{
string message = ex.Message;
}
finally
{
if (flagItemChange == true)
{
flagItemChange = false;
}
}
}
The problems I have:
1. Error: Condition is not valid .
2. When I replace the " ' " + ap.GlobalAppointmentID + " ' <> [GlobalAppointmentID]) to " ' " + ap.Subject + " ' <> [Subject])
the error is not raised but I get no item return even though I'm sure there is another appointment that should be return for the filter I wrote.
any recommendation Please help, Iram