John Joseph
John Joseph

Reputation: 951

C# Outlook Appointment User Properties - Not persisting across calendars/invitees

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.

Upvotes: 0

Views: 911

Answers (1)

John Joseph
John Joseph

Reputation: 951

So, after lots of head scratching and modifications, and after using Outlook Spy with the help of Dmitry (http://www.dimastr.com/outspy/home.htm) to inspect User Properties I realised that I had been trying to set a property name that happened to be in use already by Outlook internally (MeetingType)

After changing the name of that property, all the other user properties now persist in both the sent items and invitees' calendars.

For anyone else coming across this same issue where properties don't persist, check your property names with those set in Outlook already, could save you hours of headache!

Upvotes: 1

Related Questions