Outlook对象模型 - 检测邮箱 [英] Outlook Object Model - Detecting Mailboxes

查看:145
本文介绍了Outlook对象模型 - 检测邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下code邮箱内的Delphi 2006中BDS应用迭代前景邮箱,然后收件箱和已发送邮件:

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', UpperCase(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;

在code工作Outlook 2007中下罚款,但在2010年没有做,因为邮箱不包含单词邮箱。因此,我从Outlook和他们的收件箱子提取JUST邮箱(不公开文件夹等)的一种替代方法后已发送的邮件文件夹。任何想法?

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?

推荐答案

在Outlook文件夹可以输入并有DefaultItemType属性。更换

In Outlook folders can be typed and have a DefaultItemType property. Replacing

if Pos('MAILBOX', UpperCase(mailbox.Item[i].Name)) > 0 then

if (mailbox.Item[i].DefaultItemType = olMailItem) then

应该给你的文件夹,默认情况下只存储邮件。

should give you the folders that by default store only mail messages.

Mail邮件当然可以存储在非类型化的文件夹为好,但作为olMailItem有

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.

这篇关于Outlook对象模型 - 检测邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆