none
Tell the Outlook that changes have been done in the form region to ask for save changes RRS feed

  • Question

  • Hey,

     I'm writing an add-in for the outlook in C# - in the form region - I have a text box for the meeting type in the appointment window - now, if I change the meeting type and closes the window - the changes are not saved. But if I for example, change the meeting type textbox and change the body of the meeting - then the Outlook shows me a message and asks if I want to save the changes.

     How can I make the outlook show this message if a change have been made in my form region?

    Thanks.

    Thursday, December 26, 2013 8:51 AM

Answers

  • Hello iseif,

    You will not get any warning or message box if you don't modify the Outlook item. Note, values of your controls on the form region are not saved automatically. There are two possible ways for getting the dialog box shown to a user:

    1. Track changes on your form region and display a message box manually (using the MessageBox.Show method).

    2. Change the source Outlook item via OOM. How do you store values entered in a text box of your form region? Do you use user properties collection of the Outlook item? For example, you can track changes of text box value and create/update the corresponding user property:

    Outlook.UserProperties properties = mail.UserProperties;
    Outlook.UserProperty prop = properties.Add("Property1", Outlook.OlUserPropertyType.olText, true, Type.Missing);
    prop.Value = "hello world!";
    
    Marshal.ReleaseComObject(prop);
    Marshal.ReleaseComObject(properties);

    Then you should get a standard message box asking to save changes:

    Finally, when an appointment item with your form region is loading, you can read the saved earlier values.

    • Marked as answer by iseif Thursday, December 26, 2013 11:25 AM
    Thursday, December 26, 2013 9:44 AM
  • I found the answer.

    I was suppose so update the value of the user property in the TextChanged event so the outlook will identify a change event.

    Thanks.

    • Marked as answer by iseif Thursday, December 26, 2013 11:24 AM
    Thursday, December 26, 2013 11:24 AM

All replies

  • Hello iseif,

    You will not get any warning or message box if you don't modify the Outlook item. Note, values of your controls on the form region are not saved automatically. There are two possible ways for getting the dialog box shown to a user:

    1. Track changes on your form region and display a message box manually (using the MessageBox.Show method).

    2. Change the source Outlook item via OOM. How do you store values entered in a text box of your form region? Do you use user properties collection of the Outlook item? For example, you can track changes of text box value and create/update the corresponding user property:

    Outlook.UserProperties properties = mail.UserProperties;
    Outlook.UserProperty prop = properties.Add("Property1", Outlook.OlUserPropertyType.olText, true, Type.Missing);
    prop.Value = "hello world!";
    
    Marshal.ReleaseComObject(prop);
    Marshal.ReleaseComObject(properties);

    Then you should get a standard message box asking to save changes:

    Finally, when an appointment item with your form region is loading, you can read the saved earlier values.

    • Marked as answer by iseif Thursday, December 26, 2013 11:25 AM
    Thursday, December 26, 2013 9:44 AM
  • Thanks a lot for your detailed answer... Yes, I use user properties but I still don't get the Save Changes message - I use the following code to save the user property:

    Outlook.UserProperty meetingType = meeting.UserProperties.Find("EMMEETINGTYPE", true);
    if (meetingType == null)
    {
    	meetingType = meeting.UserProperties.Add("EMMEETINGTYPE", Outlook.OlUserPropertyType.olText, false, Outlook.OlUserPropertyType.olText);
    }
    meetingType.Value = txtMeetingType.Text;

    I do the saving in the Write event:

    meeting.Write += new ItemEvents_10_WriteEventHandler(meeting_Write);

    But if I change the content of the textbox without changing any filed of the original outlook window - I don't see the Save Changes window and the Write method is not called.

    What do you think the issue is?

    Thursday, December 26, 2013 10:01 AM
  • I found the answer.

    I was suppose so update the value of the user property in the TextChanged event so the outlook will identify a change event.

    Thanks.

    • Marked as answer by iseif Thursday, December 26, 2013 11:24 AM
    Thursday, December 26, 2013 11:24 AM
  • Hi iseif,

    The Write event is not a suitable place for such things. Instead, please try to handle the form regions control's events.

    Thursday, December 26, 2013 11:25 AM