0
votes

I have a problem with development of a Office 365 Outlook Addin (Desktop). I need to modify certain properties on a MailItem opened with a custom form ( Form designed in Outlook, exported as OFS file and imported in to Visual Studio AddIn project) but the call of method 'Save' on MailItem object doesn't working, "Saved" property remain to "false" and when i close the inspector, Outlook prompt to save current item. No exception or error message raised on 'Save' call. But if i try to call 'Save' to the same MailItem in the AddIn body, the message is saved. I tried to write a simple test "addin" and i obtained the same result, but i can't understand this behaviour.

NB: with previous version of Outlook i haven't this issue. Any idea? Thanks so much!

Currently using VS2017, C#, .NET Framework 4.5, Interop library version 15.0


    // ADD-IN BODY

    private Outlook.Inspectors inspectors;
    public static MailItem CurrentMailItem;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {     
        inspectors = this.Application.Inspectors;
        inspectors.NewInspector += Inspectors_NewInspector;
    }

    private void Inspectors_NewInspector(Inspector Inspector)
    {

        if (Inspector.CurrentItem is MailItem)
        {
            MailItem item = (MailItem)Inspector.CurrentItem;

            item.MessageClass = "IPM.Note.MyReader";
            item.Save();
            bool saved = item.Saved;
            Marshal.ReleaseComObject(item);
            item = null;
        }
    }

    // CUSTOM FORM:

    private void FormRegion2_FormRegionShowing(object sender, System.EventArgs e)
    {
        // from this.OutlookItem
        MailItem item = this.OutlookItem as MailItem;
        item.Save();
        bool saved = item.Saved; // <== SAVED=FALSE!

        // from global variable (static)    
        ThisAddin.CurrentMailItem.Save();   
        saved = ThisAddin.CurrentMailItem.Saved; // <=== SAVED=FALSE!!!!
    }  
2

2 Answers

0
votes

It seems you are using wrong event NewInspector to modify the message class. Have a look at this thread

0
votes

I think it's a problem with the specific custom form that i've created, or a compatibility problem with Outlook 2016 (the same form working with Outlook 2013)

Steps to the resolution:

It's not the definitive solution, because now i must recreate a form with Outlook 2016 and i'm not sure that it's working with previous version of Office. Moreover, the designer of Outlook 2016 have some problem with font size… i can't change font size to '8' for any label present in the form.