I am working on a VSTO Outlook Addin for new mails. User can toggle image when he wants the mail saved.
Currently when the image is clicked i set a global bool to true.
private bool _state;
private void toggleBtn_Click(object sender, RibbonControlEventArgs e)
{
if (_state) {
_state = false;
} else {
_state = true;
}
}
Which works ok until the user opens another new mail window before sending the first one.
How can i store the state per new mail window only?
Thank so much.
Solution
There are two ways to solve this problem.
One : User Properties Excellent blog on https://www.add-in-express.com/creating-addins-blog/2013/01/30/preserve-outlook-ribbon-controls-state/
Two: Use wrapper to store the state in classes Read more on https://msdn.microsoft.com/en-us/library/office/ff973716(v=office.14).aspx