0

I've created an Outlook (2010) VBScript macro that has some user-configurable settings. I've googled and checked the likely resources and can't figure out a good way to persist them. I'm currently storing them in the body of a mail item! It don't get much kludgier than that!
Should I use the Windows registry? An ini file? Or??? And whether registry, file, or???, what key/folder/??? would I use?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
jaskho
  • 122
  • 5
  • No worries about posting answering your own question - it's relevant to others (I just learned something), so keep it! I just edited out the answer from your question and the surrounding "I asked and answered a question"-stuff, so it only shows your core question. – Peter Albert Feb 13 '13 at 22:12

2 Answers2

1

Just before hitting 'Post' on this I tried one more google search and hit on this: http://www.jkp-ads.com/articles/DistributeMacro08.asp.

The gist I took away was, ini file or registry are both kosher. One nice thing about VBA's use of the registry is it automatically puts "app" data in the approved place, just need to give your "app" a key. Since my data is just a big string with parsing code already in place, I used strData = GetSetting(strAppKey, strSection, strLeafKey) and SaveSetting(strAppKey, strSection, strLeafKey, strData) and voila, all is good.

jaskho
  • 122
  • 5
0

The standard Outlook way of storing settings, especially if they relate to a particular mailbox/store and can be accessed from multiple machines connected to the same mailbox, is to use a hidden message stored in one of the well known folders, such as the Inbox.
The hidden MAPI messages can be accessed using MAPIFolder.GetStorage: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getstorage.aspx

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • For those like myself... It took me a few minutes and a couple pages of MS documentation to get clear that 1. To create a new StorageItem, simply call `Set MyItem = GetStorage(...)` with a key that doesn't already exist. 2. A StorageItem is a subclassed MailItem - so use it the same way, eg `MyItem.Body = strData` and then `MyItem.Save` – jaskho Feb 13 '13 at 23:36