【发布时间】:2014-01-30 07:33:01
【问题描述】:
我正在尝试制作一个 ASP.Net 网站,该网站将趋势和图表化每日发送到某个电子邮件地址的电子邮件总数。我不需要下载或处理邮件,只需在收件箱中返回每天的电子邮件总数。
我看到的所有编程问题都是针对 WinForms 并使用 Outlook 来计算本地 PST 文件,而在 ASP.Net 上使用 Exchange 的情况并不多。
我找到了 EWS XML 元素 > UnreadCount,但很难使用该元素。 http://msdn.microsoft.com/en-us/library/office/aa580965(v=exchg.150).aspx
我开始使用的程序代码是为了在桌面上工作,但是我不想把它作为桌面服务留下来浪费资源并放弃这个挑战。
' Create Application class and get namespace
Dim outlook As Outlook.Application = New Outlook.ApplicationClass()
Dim ns As Outlook.NameSpace = outlook.GetNamespace("Mapi")
Dim _missing As Object = Type.Missing
ns.Logon(_missing, _missing, False, True)
' Get Inbox information in objec of type MAPIFolder
Dim inbox As Outlook.MAPIFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
' Unread emails
Dim unread As Integer = inbox.UnReadItemCount
' Display the subject of emails in the Inbox folder
For Each mail As Outlook.MailItem In inbox.Items
Console.WriteLine(Wmail.Subject)
Next mail
【问题讨论】:
-
您使用标志,当您阅读电子邮件时,您设置已阅读标志,然后计算标志。
标签: asp.net graph exchange-server exchangewebservices