folder->get_Store fails

T

tnemec78

Hi,
in my code I use folder->get_Store(&store); which crashes the app on
Outlook XP (Outlook 2007 works fine) Did anyone else experience this?
Am I doin anything wrong? The crash occurs inside of my
OnSelectionChange handler immediately after the Outlook starts.

Any hints?
 
T

tnemec78

Additional info:
After having explored the XP version of MSOUTL.OLB in OleView I
realise that there is no such method as get_Store. The _Namespace
property in this version does not have the GetStoreFromID method
either.
So how do I get from a MAPIFolder to _Store object in these early
versions of Outlook?
 
K

Ken Slovak - [MVP - Outlook]

Are you talking about the Folder.Store() property in the Outlook 2007 object
model? Not only doesn't Folder exist in older versions of Outlook, but the
older MAPIFolder object has no Store property.

If you are going to develop for multiple versions of Outlook you can only
use methods that exist on the oldest version you plan to support. If you are
running on newer versions you can use Reflection or late binding to access
properties and methods on the newer version, but they still won't exist on
older versions of Outlook.
 
K

Ken Slovak - [MVP - Outlook]

Store objects are not exposed at all in the Outlook object model before
Outlook 2007. You can get a store from CDO 1.21 or from a 3rd party library
such as Redemption (www.dimastr.com/redemption).

What do you want to do with the Store object?
 
T

tnemec78

I wanted to get to the Root Folder of a particular PST file. And I
found a Store->GetRootFolder() method. (2007 only)
So now I suppose I shall simple do something like
do
{
hr = folder->get_Parent(&folder2);
if(SUCCEEDED(hr))
folder = folder2;
}while(SUCCEEDED(hr));
once the call fails - I get out of the loop and that's when I will
have the root folder. correct?
 
T

tnemec78

I wanted to do 2 thing:
1stly: get to the Root Folder of a particular PST file.
I found a Store->GetRootFolder() method. (2007 only)
So now I suppose I shall simple do something like
while(true)
{
parent = NULL;
folder->get_Parent((IDispatch **)&parent);
dummy = NULL;
hr = parent->QueryInterface(__uuidof(MAPIFolder), (LPVOID *)&dummy);
if(FAILED(hr))
{
break;
}
folder.Release();
folder = parent;
}
once the call fails - I get out of the loop and that's when I will
have the root folder. correct?

2ndly: I wanted to call istore->GetReceiveFolder("IPM.Note", ...)
Here I am left clueless as to how to achieve this without the _Store
or IStore object ... Are there any tricks to use for Outlooks prior to
2007? (I am not using redemption or any other 3rd party tool right now)
 
T

tnemec78

I wanted to do 2 thing:
1stly: get to the Root Folder of a particular PST file.
I found a Store->GetRootFolder() method. (2007 only)
So now I suppose I shall simple do something like
while(true)
{
parent = NULL;
folder->get_Parent((IDispatch **)&parent);
dummy = NULL;
hr = parent->QueryInterface(__uuidof(MAPIFolder), (LPVOID *)
&dummy);
if(FAILED(hr))
{
break;
}
folder.Release();
folder = parent;
}

once the call fails - I get out of the loop and that's when I will
have the root folder. correct?

2ndly: I wanted to call get to the Inbox folder of a given PST file.
What I did again was to call folder->get_Store() then store-
get_MAPIOBJECT() and finally istore->GetReceiveFolder
("IPM.Note", ...)
Here I am left clueless as to how to achieve this without the _Store
or IMsgStore objects ...

Are there any tricks to use for Outlooks prior to 2007? (I am not
using redemption or any other 3rd party tool right now)
 
K

Ken Slovak - [MVP - Outlook]

NameSpace.Folders returns all the top level folders of stores that are
opened. Each MAPIFolder object in that top level collection is the
equivalent of the OutlookToday folder which corresponds to the IPM_SUBTREE
root folder.

An alternative is to get a folder as you say and keep traveling up the
hierarchy getting the parent folder until there are no more parents
available in the Outlook object model.

You can than iterate every top level folder under the IPM_SUBTREE hierarchy
looking for a folder where DefaultItemType == 5. The folder name would be
language dependent, if it's always English you can check the folder name for
"Notes". If language can vary then the above is the only way, but it doesn't
help you if the user has created another folder for note items at that same
top level.

With an alternate API you could read the PR_IPM_NOTE_ENTRYID (0x36D30102)
value from the Inbox folder properties and convert that PT_BINARY into a hex
string EntryID and use that to get the folder (NameSpace.GetFolderFromID)
for the default Notes folder. But you can do that only with other API's for
versions of Outlook earlier than 2007.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top