如何:检索收件箱中的未读邮件
更新:2007 年 11 月
适用对象 |
---|
本主题中的信息仅适用于指定的 Visual Studio Tools for Office 项目和 Microsoft Office 版本。 项目类型
Microsoft Office 版本
有关更多信息,请参见按应用程序和项目类型提供的功能。 |
本示例从 Outlook“收件箱”中检索未阅读的电子邮件并显示项数。
示例
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Dim inbox As Outlook.MAPIFolder = _
Me.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim unreadItems As Outlook.Items = _
inbox.Items.Restrict("[Unread]=true")
MessageBox.Show( _
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.Session.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items unreadItems = inbox.
Items.Restrict("[Unread]=true");
MessageBox.Show(
string.Format("Unread items in Inbox = {0}", unreadItems.Count));
}