I am developing a VSTO project where i want to save some user data using roaming settings i searched for it and it is applicable only in javascript office.js Is there any alternative that i can use in my VSTO project?
using Outlook = Microsoft.Office.Interop.Outlook;
CodePudding user response:
You can save user settings in the user roaming profile. To add a user setting, go to project properties (right click the project => Properties), then navigate to the "Settings" tab and add your user setting there:
https://learn.microsoft.com/en-us/visualstudio/ide/reference/settings-page-project-designer
CodePudding user response:
JS addin roaming settings are stored in the Exchange mailbox outside of the visible (IPM) folder tree. Outlook itself stores its global settings (e.g., categories etc.) in a hidden message (each folder has two contents tables - regular and hidden) in one of the default folders, such as Inbox or Calendar - you can see those messages in OutlookSpy (I am its author) - click IMAPIFolder button, go to the "Associated Contents" tab.
You can access these message in your VSTO project through MAPIFolder.GetStorage.
CodePudding user response:
You can use hidden items in Outlook. That is how roaming settings are stored by web add-ins. The Outlook object model provides the StorageItem
object which is stored at the folder level, allowing it to roam with the account and be available online or offline.
The Outlook object model does not provide any collection object for StorageItem
objects. However, you can use Folder.GetTable
to obtain a Table
with all the hidden items in a Folder
, when you specify the TableContents
parameter as olHiddenItems
. Be aware, if keeping your data private is of a high concern, you should encrypt the data before storing it.
Once you have obtained a StorageItem
object, you can do the following to store solution data:
- Add attachments to the item for storage.
- Use explicit built-in properties of the item such as
Body
to store custom data. - Add custom properties to the item using
UserProperties.Add
method. Note that in this case, the optionalAddToFolderFields
andDisplayFormat
arguments of theUserProperties.Add
method will be ignored. - Use the
PropertyAccessor
object to get or set custom properties.
For more information on storing solution data in Outlook see Storing Data for Solutions.