1
votes

I have an outlook addin in which I update programmatically user properties.

Until now, I executed the addin and outlook with administrator rights. Everything was working good.

I attach the event on a forwarded mail :

    void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    {
        try
        {
            MailItem mail = Inspector.CurrentItem as MailItem;
            if (mail != null)
            {
                ((Outlook.ItemEvents_10_Event)mail).Forward += new ItemEvents_10_ForwardEventHandler(Forward_Event);
        }
        finally
        {
            Marshal.ReleaseComObject(Inspector);
        }
    }

Then I update the user properties of the mail and save it.

    void Forward_Event(object Forward, ref bool Cancel)
    {
        MailItem mail = Forward as MailItem;
        if (mail != null && OutlookHelper.GetUserProperty(mail) != null)
        {
            OutlookHelper.SetUserProperty(mail, null);
            EventLog.WriteEntry("Application", "Before save forward : " + mail.Saved); // mail.Saved = false
            mail.Save();
            EventLog.WriteEntry("Application", "After save forward : " + mail.Saved); // mail.Saved = true
        }
    }

I can see in the logs that the property Saved of my mail is set to True after the call to the Save() method.

However, since I use a standard user to execute the addin (linked to customer needs), when I close the email, a popup appears asking me to save manually the user properties of the forwarded mail. The problem does not appear with admin rights.

Thanks to everybody for help

1

1 Answers

0
votes

Well, after some intensive researches, the mail is "read only" and then the call to the Save() method does not really save. When I removed the call to the save, the popup disappeared... I do not really understand this behavior, but it works !

Hope this will help some other people.