VBA Outlook Mailitem – 不显示所有项目
下面的代码不会收到收件箱中的所有电子邮件。
我的列表框中的第一项是昨天和去年4月22日的一封电子邮件,尽pipe我的邮箱里包含了很多信息。
Sub CheckEmail() On Error Resume Next Dim outApp As Outlook.Application Dim outNs As Outlook.Namespace Dim outFldr As Outlook.MAPIFolder Dim outEmail As Outlook.MailItem Dim p As Integer p = 0 Set outApp = CreateObject("Outlook.Application") Set outNs = outApp.GetNamespace("MAPI") Set outFldr = outNs.GetDefaultFolder(olFolderInbox) Dim searcht As String 'find search string ' do search For Each outEmail In outFldr.Items With fmShowsInboxEmails.ListBox1 .AddItem outEmail.EntryID .List(p, 1) = outEmail.ReceivedTime .List(p, 2) = outEmail.Subject .List(p, 3) = outEmail.SenderEmailAddress .List(p, 4) = outEmail.Attachments.Count End With p = p + 1 Next outEmail On Error GoTo 0 Set outApp = Nothing Set outNs = Nothing Set outFldr = Nothing Set outEmail = Nothing fmShowsInboxEmails.Show End Sub
“下一个outEmailtypes不匹配”
收件箱中的项目不必是邮件项目。
一旦你有Dim OutEmail As Variant,在添加到列表框之前,testingoutEmail是一个mailitem。
我认为Outlook只计算在脱机文件夹本地存储的项目 – 所以存储在服务器上的消息不会是outFldr.Items的一部分