我只想在我的收件箱中选择包含(在Body中)某个字符串的所有邮件。我认为Find会很好。而不是对收件箱中的所有项目进行for..each ... 但是我的命令(见下文)不起作用。它带来了"无效条件"
设置Msg = Inbox.Items.Find(" abc")
2个问题:
1.如何填写所需条件?
2.那个发现的结果是什么?单个电子邮件或我需要放入变体的集合
答案 0 :(得分:0)
Find方法找到并返回满足给定Filter的Microsoft Outlook项目对象。有关可能的查询字符串的详细信息,请参阅Filtering Items Using Query Keywords。运行Find方法后,FindNext方法查找并返回指定集合中的下一个Outlook项。例如:
Sub DemoFindNext()
Dim myNameSpace As Outlook.NameSpace
Dim tdystart As Date
Dim tdyend As Date
Dim myAppointments As Outlook.Items
Dim currentAppointment As Outlook.AppointmentItem
Set myNameSpace = Application.GetNamespace("MAPI")
tdystart = VBA.Format(Now, "Short Date")
tdyend = VBA.Format(Now + 1, "Short Date")
Set myAppointments = myNameSpace.GetDefaultFolder(olFolderCalendar).Items
Set currentAppointment = myAppointments.Find("[Start] >= """ & tdystart & """ and [Start] <= """ & tdyend & """")
While TypeName(currentAppointment) <> "Nothing"
MsgBox currentAppointment.Subject
Set currentAppointment = myAppointments.FindNext
Wend
End Sub