如何:检索收件箱中的未读邮件
本示例从 Outlook**“收件箱”**中检索未阅读的电子邮件并显示项数。
**适用于:**本主题中的信息适用于 Outlook 2007 和 Outlook 2010 的应用程序级项目。有关更多信息,请参见按 Office 应用程序和项目类型提供的功能。
示例
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Dim inbox As Outlook.MAPIFolder = _
Me.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim unreadItems As Outlook.Items = _
inbox.Items.Restrict("[Unread]=true")
MsgBox(String.Format("Unread items in Inbox = {0}", unreadItems.Count))
End Sub
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.MAPIFolder inbox =
this.Application.ActiveExplorer().Session.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items unreadItems = inbox.
Items.Restrict("[Unread]=true");
MessageBox.Show(
string.Format("Unread items in Inbox = {0}", unreadItems.Count));
}