Gerwald
Gerwald

Reputation: 1589

VSTO Outlook User Properties (Custom) not syncing

I have the problem that when i add a custom UserProperty to an Outlook MailItem, it does not get synced to other connected Outlooks.

What can i do to force Outlook to sync the whole email?

My overal problem: I've got a shared Exchange Mailbox, opened on two clients (in Outlook) I would like to lock a mail item, if it gets opened in one Outlook and show the second Outlook user a message like "The user XX is currently reading this email"

My way to solve the problem: Creating a Outlook Plugin. When user "A" is opening the Email, I am adding a "LockingUser" UserProperty to the MailItem object. If user "B" is trying to open the Email, I am first looking if a "LockingUser" Property exists. I have disabled the cached mode. I have tried to update the subject of the email: this works perfectly and gets synced immediatly (but is not a solution for my problem)

private void SetLockingUser(Outlook.MailItem mail)
{
    var lockingUserProperty = mail.UserProperties.Find("LockingUser");
    if (lockingUserProperty != null)
    {
        MessageBox.Show("Email locked by: " + lockingUserProperty.Value);
        return;
    }

    var identity = System.Security.Principal.WindowsIdentity.GetCurrent();
    var username = identity != null ? identity.Name : "";

    lockingUserProperty = mail.UserProperties.Add("LockingUser", Outlook.OlUserPropertyType.olText, false, 1);
    lockingUserProperty.Value = username;
    mail.Save();
}

Upvotes: 0

Views: 1447

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66276

Please show the relevant snippet of your code and make sure you call MailItem.Save. Also keep in mind that there will always be lag since the changes will take up to a couple minutes to sync to Exchange and then to another user if cached mode is used. You'd be better off using some external sync mechanism instead of a user property.

Upvotes: 1

Related Questions