gpt4 book ai didi

excel - VBA Outlook Mailitem - 不显示所有项目

转载 作者:行者123 更新时间:2023-12-04 20:16:26 24 4
gpt4 key购买 nike

下面的代码不会收到我在收件箱中的所有电子邮件。

我列表框中的第一项是昨天和 2014 年 4 月 22 日最后一封电子邮件——尽管我的邮箱包含的远不止这些。

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

最佳答案

“下一个 outEmail 上的类型不匹配”

收件箱中的项目不必是邮件项目。

一旦您将 outEmail 作为 Variant 变暗,请在添加到列表框之前测试 outEmail 是一个邮件项。

关于excel - VBA Outlook Mailitem - 不显示所有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24003325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com