locked
Save AppointmentItem content after changing GetInspector.WordEditor RRS feed

  • Question

  • Hi,

     

    I creating simple application that search for appointments with attachments in outlook calendar, when I find appointment with attachment I copying the attachment to some folder and adding link to the file in the appointment (reduce the quota).

     

    When I'm opening the appointment in Outlook after editing it from the code everything looks fine but when I try to close the appointment window it will ask me to save the appointment. If I choose not to save, all my WordEditor changes will be removed.

     

    Also the GetInspector property is read only so I can't assign anything there.

     

    Code sample:

    foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in calendarFolder.Items)

                {

                    if (item.Subject != null)

                    {

    object x = item.GetInspector.WordEditor; docWord.Document document = (docWord.Document)x;

    //for example

    document.Content.InsertParagraphBefore(); document.Content.InsertParagraphBefore();

    }

    item.Save();

    }

    How can I can save these WordEditor changes?

    Thank you,

    Jen4ik

    Sunday, January 2, 2011 12:40 PM

Answers

  • Hi Dmitry,

    If I restart outlook no WordEditor data will be saved.

    I solve the issue. The problem was,  I couldn't force outlook to save the changes of WordEditor, not of the AppointmentItem (all AppointmentItem's proprties was saved for example if i change Location and apply the save method it will save the location).

    I have noticed when I display the AppointmentItem after using the save method then i close the appointment, everything work fine but it will pop up the appointment for less then a second. So I have found in MSDN piece of code in VB that helped me to solve my issue.

    The solution was:

    ----------------------------------------------------------------------------------------

     

    Candidate.Save();

    Outlook.Inspector curr_inspector = Candidate.GetInspector;

    Outlook.Pages curr_page = curr_inspector.ModifiedFormPages;

    curr_page.Add("General");

    curr_inspector.HideFormPage("General");

    Candidate.Close(Outlook.OlInspectorClose.olSave);

    ----------------------------------------------------------------------------------------

     

    Outlook = Microsoft.Office.Interop.Outlook;

    Candidate is AppointmentItem

     

    Regards,

    Jen4ik

     

    Tuesday, January 4, 2011 2:45 PM

All replies

  • Do you have the same problem is you restart Outlook and your app after making the changes but before opening the appointment?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Monday, January 3, 2011 4:50 PM
  • Hi Dmitry,

    If I restart outlook no WordEditor data will be saved.

    I solve the issue. The problem was,  I couldn't force outlook to save the changes of WordEditor, not of the AppointmentItem (all AppointmentItem's proprties was saved for example if i change Location and apply the save method it will save the location).

    I have noticed when I display the AppointmentItem after using the save method then i close the appointment, everything work fine but it will pop up the appointment for less then a second. So I have found in MSDN piece of code in VB that helped me to solve my issue.

    The solution was:

    ----------------------------------------------------------------------------------------

     

    Candidate.Save();

    Outlook.Inspector curr_inspector = Candidate.GetInspector;

    Outlook.Pages curr_page = curr_inspector.ModifiedFormPages;

    curr_page.Add("General");

    curr_inspector.HideFormPage("General");

    Candidate.Close(Outlook.OlInspectorClose.olSave);

    ----------------------------------------------------------------------------------------

     

    Outlook = Microsoft.Office.Interop.Outlook;

    Candidate is AppointmentItem

     

    Regards,

    Jen4ik

     

    Tuesday, January 4, 2011 2:45 PM
  • That makes sense!
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Tuesday, January 4, 2011 2:58 PM