3

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.

Nick DK
  • 41
  • 4
  • I'm running into the same problem - did you find a solution yet? – mnkypete May 30 '14 at 17:13
  • The only solution I found so far is getting the text directly via the window API.. you need to look up the HWND of the text box in the window tree and then use GetWindowText of the Win32 API to retrieve the contents.. That actually works but is very hacky.. – mnkypete May 30 '14 at 18:33

2 Answers2

0

Its happening because you have placed your curser in the subject field of your item. If you remove the focus from subject field it will work.

Yes you are right by expanding dynamic view all of a sudden subject text appears, but that my be due to delay or something that i don't know.

0

m_item - A variable that represents an AppointmentItem object

m_item.Save() - "trigger" dynamic view obj, now you have data on m_item.Subject

Eden M
  • 171
  • 1
  • 2
  • 15