Is there a way to persist user properties across to the appointment invitees/locations calendars?
I have created a form region for appointments, with some extra form fields on. Upon the appointment write event, I can save the form region data as user properties against the appointment. From the senders' point of view, these properties persist when the item is opened up, and can be updated etc.
However, any invitees on the appointment, or any meeting rooms/locations included can receive the appointment BUT the user properties don't seem to carry across with the item. Why is this, and can it be worked around?
The only one I could think of is to persist the user properties in a database also and load them upon item open with the FormRegion_Showing
method. That's not ideal though as the whole point was to keep it all in outlook.
I'm using Outlook 2010 and Visual Studio 2015.
I came across this post which pretty much says it can't be done, however that is from 2011 and I can't find anything more recent that's relevant to this particular scenario.
Some cut down code - the Form Region:
// Form region class
[Microsoft.Office.Tools.Outlook.FormRegionMessageClass(Microsoft.Office.Tools.Outlook.FormRegionMessageClassAttribute.Appointment)]
[Microsoft.Office.Tools.Outlook.FormRegionName("Namespace.MyFormRegion")]
public partial class MyFormRegionFactory
{
}
private void MyFormRegion_FormRegionShowing(object sender, System.EventArgs e)
{
Outlook.AppointmentItem appointment = this.OutlookItem as Outlook.AppointmentItem;
this.appointment.Write += Appointment_Write;
}
private void Appointment_Write(ref bool Cancel)
{
Outlook.ItemProperties CateringData = this.appointment.ItemProperties;
var Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
Outlook.ItemProperty MeetingNameProperty = CateringData.Add("MeetingName", Outlook.OlUserPropertyType.olText, true);
MeetingNameProperty.Value = this.MeetingName.Text;
// More properties saved
appointment.Save();
}
and in the addin class:
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Application.ItemSend += Application_ItemSend;
}
private void Application_ItemSend(object Appointment, ref bool Cancel)
{
// Appointment is an AppointmentItem that has just been saved.
// How does this relate to the outgoing item that ends up in the
// Sent Items folder???
}
}
Using Outlook Spy the user properties are not in the item within the Sent Items. The form region does appear when opening the item from one of the invitees calendars, but the user properties are not there.