J
juvi
hello,
I have the following code to read outlook appointments. I am only interested
in the next/upcoming appointment. Is there a more performance-friendly way to
do this?
try
{
OutlookSession session = new OutlookSession();
AppointmentFolder appointments = session.Appointments;
appCount = 0;
foreach (Appointment a in appointments.Items)
{
if (a.Location != "")
{
s = a.Start.ToShortDateString() + ": " + a.Subject +
" (" + a.Location + ")";
}
else
{
s = a.Start.ToShortDateString() + ": " + a.Subject;
}
if (a.Start > DateTime.Now)
{
appCount = 1;
goto NextTask;
}
}
NextTask:
if (appCount == 0)
goto NoAppointments;
foreach (Appointment a in appointments.Items)
{
s = a.Start.ToShortTimeString() + " - " +
a.End.ToShortTimeString();
}
NoAppointments:
if (appCount == 0)
{
}
session.Dispose();
appointments.Dispose();
}
catch
{
}
I have the following code to read outlook appointments. I am only interested
in the next/upcoming appointment. Is there a more performance-friendly way to
do this?
try
{
OutlookSession session = new OutlookSession();
AppointmentFolder appointments = session.Appointments;
appCount = 0;
foreach (Appointment a in appointments.Items)
{
if (a.Location != "")
{
s = a.Start.ToShortDateString() + ": " + a.Subject +
" (" + a.Location + ")";
}
else
{
s = a.Start.ToShortDateString() + ": " + a.Subject;
}
if (a.Start > DateTime.Now)
{
appCount = 1;
goto NextTask;
}
}
NextTask:
if (appCount == 0)
goto NoAppointments;
foreach (Appointment a in appointments.Items)
{
s = a.Start.ToShortTimeString() + " - " +
a.End.ToShortTimeString();
}
NoAppointments:
if (appCount == 0)
{
}
session.Dispose();
appointments.Dispose();
}
catch
{
}