J
JamesB
Hi,
I am adding an option to my application (a specialised "diary" program) to
allow users to add items into their outlook calendar.
This works fine, and I am returning the Outlook ID back into the database.
The problem is if the user wants to change details in my app and re-add it
to outlook. It needs to edit the Outlook entry, not add another new one.
Code stuff:
using Microsoft.Office.Interop.Outlook;
....
Object tObj;
AppointmentItem aic;
//Is this appointment already in Outlook?
if (AppRDR["appt_outlook_guid"] == null)
{
tObj =
olApp.CreateItem(OlItemType.olAppointmentItem);
aic = (AppointmentItem)tObj;
aic.AllDayEvent =
Convert.ToBoolean(AppRDR["appt_alldayevent"]);
aic.Start =
Convert.ToDateTime(AppRDR["appt_startdate"]);
aic.End =
Convert.ToDateTime(AppRDR["appt_enddate"]);
aic.Body = AppRDR["appt_notes"].ToString();
aic.Subject = AppRDR["appt_description"].ToString();
aic.Save();
}
else
{
tObj =
olApp.CreateItem(OlItemType.olAppointmentItem);
aic = (AppointmentItem)tObj;
aic.AllDayEvent =
Convert.ToBoolean(AppRDR["appt_alldayevent"]);
aic.Start =
Convert.ToDateTime(AppRDR["appt_startdate"]);
aic.End =
Convert.ToDateTime(AppRDR["appt_enddate"]);
aic.Body = AppRDR["appt_notes"].ToString();
aic.Subject = AppRDR["appt_description"].ToString();
aic.GlobalAppointmentID =
AppRDR["appt_outlook_guid"].ToString();
aic.Save();
}
The problem is in the "else" part - in the last but one line I am trying to
set the guid on my new appointment object to the one in the database, hoping
this would just update the entry in Outlook with that ID, but it tells me it
is read only.
Looking through the methods available and stuff, I can't see an "EditItem"
equivalent, only CreateItem.
Any clues?
James.
I am adding an option to my application (a specialised "diary" program) to
allow users to add items into their outlook calendar.
This works fine, and I am returning the Outlook ID back into the database.
The problem is if the user wants to change details in my app and re-add it
to outlook. It needs to edit the Outlook entry, not add another new one.
Code stuff:
using Microsoft.Office.Interop.Outlook;
....
Object tObj;
AppointmentItem aic;
//Is this appointment already in Outlook?
if (AppRDR["appt_outlook_guid"] == null)
{
tObj =
olApp.CreateItem(OlItemType.olAppointmentItem);
aic = (AppointmentItem)tObj;
aic.AllDayEvent =
Convert.ToBoolean(AppRDR["appt_alldayevent"]);
aic.Start =
Convert.ToDateTime(AppRDR["appt_startdate"]);
aic.End =
Convert.ToDateTime(AppRDR["appt_enddate"]);
aic.Body = AppRDR["appt_notes"].ToString();
aic.Subject = AppRDR["appt_description"].ToString();
aic.Save();
}
else
{
tObj =
olApp.CreateItem(OlItemType.olAppointmentItem);
aic = (AppointmentItem)tObj;
aic.AllDayEvent =
Convert.ToBoolean(AppRDR["appt_alldayevent"]);
aic.Start =
Convert.ToDateTime(AppRDR["appt_startdate"]);
aic.End =
Convert.ToDateTime(AppRDR["appt_enddate"]);
aic.Body = AppRDR["appt_notes"].ToString();
aic.Subject = AppRDR["appt_description"].ToString();
aic.GlobalAppointmentID =
AppRDR["appt_outlook_guid"].ToString();
aic.Save();
}
The problem is in the "else" part - in the last but one line I am trying to
set the guid on my new appointment object to the one in the database, hoping
this would just update the entry in Outlook with that ID, but it tells me it
is read only.
Looking through the methods available and stuff, I can't see an "EditItem"
equivalent, only CreateItem.
Any clues?
James.