繁体   English   中英

VBA无法在outlook中使用.Find查找电子邮件

[英]VBA can't find emails in outlook using .Find

我创建了一个在我的计算机上运行良好的宏。 当我在另一台计算机上上传并运行它时,它找不到任何电子邮件。

Set olApp = GetObject(, "Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
Set olItms = olFldr.Items
Set olEmail = olApp.CreateItem(olMailItem)


 Set OutApp = CreateObject("Outlook.Application")
 Set OutMail = OutApp.CreateItem(0)


            subj = "Test email"

                Set olMi = olItms.Find("[Subject] = " & Chr(34) & subj & Chr(34))
              If Not (olMi Is Nothing) Then
                        For Each olAtt In olMi.Attachments
              Else
                  ' ends up here everytime

我给自己发了一封名为“测试电子邮件”的电子邮件,我可以在我的Outlook收件箱中看到它但我的宏却找不到它(在我上传宏的任何计算机上)。 但是,当我在原始计算机上运行程序时,我编写了程序,它工作正常。 不确定问题是什么。

尝试搜索PR_NORMALIZED_SUBJECT MAPI属性:

set olMi = olItms.Find("@SQL=""http://schemas.microsoft.com/mapi/proptag/0x0E1D001F"" = '" & subj & "'")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM