Product SiteDocumentation Site

4.2. Opening a store

So now we have a session, it’s time to open a store. A store is basically an entire tree of folders that the user can use. Normally each new profile has two stores: the user’s own store, and the public store. Most applications will want to open the user’s own store, known as the default store. Again, MAPI.Util provides a convenient function to do this, GetDefaultStore().
store = GetDefaultStore(session)
Now we have a store. The store has a set of properties like the name of the store and it’s unique identifier. The store object itself is just a reference to the c+\+ object beneath so to get properties we have to use the GetProps() method to get information:
from MAPI.Tags import *

props = store.GetProps([PR_DISPLAY_NAME], 0)
You can see here that we need to import another module, MAPI.Tags. This module contains the symbolic names of all of the standard MAPI properties, like PR_DISPLAY_NAME. In reality, PR_DISPLAY_NAME is just an int specifying a property ID (a 16-bit integer identifier) and a type (also a 16-bit identifier). In this case, PR_DISPLAY_NAME is equal to 0x3001001e, with 0x3001 being the ID part, and 0x001e being the type (PT_STRING8).
GetProps() accepts a list of properties, but since we only want one for now, that’s fine. Now we have the property, we can print the value:
print props[0].Value + '\n'
The returned value from GetProps() is a list of SPropValue() class instances, which is a simply object containing the two values of the c+\+ SPropValue structure:
The returned value in ulPropTag is the same as the requested property, PR_DISPLAY_NAME. This may seem redundant, but as we will see later, it can in some cases be different from the requested property (usually in error conditions).
The number of items in the list returned by GetProps() will always be exactly equal to the number of requested properties in the GetProps() call. You can also pass None as the property list, which will cause GetProps() to return all the properties in the object.