I have issues accessing the actual typed-in text in Subject field of an AppointmentItem. I have created an Outlook 2010 add-in that has a callback from a custom button from the ribbon. I can get the value of the Subject field except if someone is clicking the button right after typing the subject (and not changing control focus). In these cases I'm getting the previous value of the Subject and not the recently typed in value. (for a newly created Meeting Invitation I get a null value)
public void ToggleMeetingPlace_Callback(Office.IRibbonControl control)
{
if ((control!=null)&&(control.Id == "toggleMeetingPlace"))
{
var item = control.Context as Outlook.Inspector;
if ((item != null) && (item.CurrentItem != null))
{
Outlook.AppointmentItem m_item = item.CurrentItem as Outlook.AppointmentItem;
string subject = m_item.Subject;
// some action
}
}
}
However if I start to debug I see some interesting behavior in the watch window: - directly watching m_item.Subject returns still the old value - but if I set up a watch for m_item and then expand the Dynamic members all of a sudden the value is updated to the current text.
I guess the dynamic view in this case has some side effects that come in handy... I just can't figure out how to do this from code.