Well, you can only use GetDefaultFolder() with folders in your default mail
store (where email is delivered for that Outlook profile). So that method
won't help you at all for non-default stores.
If you use a MAPI viewer such as OutlookSpy you can see that on the Store
object (IMsgStore button) in any open store there are properties there that
contain the folder EntryID's of certain default folders:
PR_IPM_OUTBOX_ENTRYID 0x35E20102
PR_SENTMAIL_ENTRYID 0x35E40102
PR_IPM_WASTEBASKET_ENTRYID 0x35E30102
Those contain the EntryID's for respectively the Outbox, Sent Items and
Deleted Items folders.
Then in the Inbox (IMAPIFolder button) there a
PR_IPM_APPOINTMENT_ENTRYID 0x36D00102
PR_IPM_CONTACT_ENTRYID 0x36D10102
PR_IPM_DRAFTS_ENTRYID 0x36D70102
PR_IPM_JOURNAL_ENTRYID 0x36D20102
PR_IPM_NOTE_ENTRYID 0x36D30102
PR_IPM_TASK_ENTRYID 0x36D40102
Those are for the Calendar, Contacts, Drafts, Journal, Notes and Tasks
default folders.
You can read those properties from the Store, navigate down through
PR_IPM_SUBTREE_ENTRYID (0x35E00102) and get to the visible folders where you
can check each folder in that hierarchy for a folder that has the Calendar,
etc. properties, that's the Inbox.
That will tell you what you want I think, but to do those operations you
would need to be using Outlook 2007 or in earlier versions of Outlook using
an alternate API such as Extended MAPI, CDO 1.21 or Redemption
(
www.dimastr.com/redemption). Then for other folders you fall back to
DefaultItemType to get the folder types.
You also have to be careful about comparing EntryID's, you can't just test
them for string or binary array equality. You should use one of the
CompareID's methods using those other API's or Outlook 2007.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:96aec03122aa6@uwe...
Hi, ken, that's not exactly what i want, DefaultItemType is only show me
what
kind of item the folder will hold, MailItem, appointment, contact. I want
to
set the CTreeCtrl item's icon, and this item is a MAPIFolder, so i want to
know it's kind, the kind include "inbox, outbox, sent items, deleted
items,
junk e-mails, drafts."
My method not work because the string is not always the same language, my
local system(XP pro) is Chinese system, but my hotmail account registered
using English info. So the folder names are all in a muddle. Some are
English and others are Chinese. This is special case, normally all message
store folders in my outlook are Chinese.