简体   繁体   中英

Why is the Appointment.Conflicts.Count always 0?

I'm using C# to go through and get all of my appointments in my outlook calender and trying to figure out if I have any conflicts, but when I check Appointment.Conflicts.Count, it's always 0, even though I've added multiple appointments that occur at the same time.

Here's some example code:

var outlook = new Microsoft.Office.Interop.Outlook.Application();
var calendar = outlook.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

Outlook.AppointmentItem appointment;
foreach (Outlook.AppointmentItem item in calendar.Items)
{
    if (item.Conflicts.Count > 0)
    {
        Console.WriteLine("Never gets hit");
    }

}

How do I determine if an appointment in Outlook conflicts with another appointment programmatically in C#?

It appears the Conflicts property is only for dealing with edit conflicts, not with scheduling conflicts.

See: Conflict Resolution for Standard Outlook Item Types

Also note that nearly all of the outlook item types also have a conflicts property, even those that don't have scheduling properties (eg NoteItem ).

It appears you will have to examine the date ranges yourself via the appointmentItem.Start and appointmentItem.End properties, and perhaps the AllDayEvent property as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM