I have a Delphi 2006 BDS application with the following code to iterate outlook mailboxes and then the Inbox and Sent Items within the mailbox:
  try
    nameSpace := outlook.GetNameSpace('MAPI');
    // load the mailboxes
    mailbox := NameSpace.Folders;
    for i := 1 to mailbox.Count do
      if Pos('MAILBOX', Uppe开发者_JAVA百科rCase(mailbox.Item[i].Name)) > 0 then
      begin
        rootNode := trvwOutlookFolders.Items.AddChildObject(nil, mailbox.Item[i].Name, nil);
        for j := 1 to mailbox.Item[i].Folders.Count do
          if (Pos('INBOX', UpperCase(mailbox.Item[i].Folders[j].Name)) > 0) or
             (Pos('SENT ITEMS', UpperCase(mailbox.Item[i].Folders[j].Name)) > 0) then
          begin
        // do processing
          end;
      end;
  finally
    outlook := Unassigned;
  end;
end;
The code works fine under Outlook 2007 but doesn't in 2010 because the mailboxes do not contain the word 'Mailbox'. Therefore I am after an alternative method of extracting JUST the mailboxes (not public folders etc) from within Outlook and their subsequence Inbox and sent items folders. Any ideas?
In Outlook folders can be typed and have a DefaultItemType property. Replacing
if Pos('MAILBOX', UpperCase(mailbox.Item[i].Name)) > 0 then
with
if (mailbox.Item[i].DefaultItemType = olMailItem) then
should give you the folders that by default store only mail messages.
Mail messages can of course be stored in untyped folders as well, but as olMailItem has
olMailItem = $00000000;
as its value, it is the default for all untyped folders as well. So basically any untyped folder by default stores mail items.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论