我目前正在开发一个 Outlook 应用程序,它在测试期间似乎运行良好。
这段代码似乎MSGBox("ASDFG")
在 就位(rsts.Count
returns 1
)时有效,但一旦它被删除,语句就会返回0
。我试图通过添加Debug.Print
's 来超越这一点,看看这是否有任何区别,但我仍然发现代码只有在 'sMSGBox
到位时才能正确运行。
如果脚本返回 0,我什至添加了一个Timer1
间隔以每秒重新运行脚本。
Function myThread()
Dim oApp As Outlook.Application = CreateObject("Outlook.application")
Dim sch As Outlook.Search
Dim rsts As Outlook.Results
Dim i As Integer
Dim myTaskSearch As String = ToolStripStatusLabel2.Text
Dim strF As String = "urn:schemas:mailheader:subject LIKE '%Task: " & myTaskSearch & "%'"
Const strS As String = "Inbox"
Try
sch = oApp.AdvancedSearch(strS, strF)
rsts = sch.Results
MsgBox("ASDFG")
Debug.Print(sch.Results.ToString)
Debug.Print("'" & myTaskSearch & "'")
If rsts.Count = 0 Then
Debug.Print(rsts.Count)
Timer1.Interval = 1000
Timer1.Start()
End If
For i = 1 To rsts.Count
Debug.Print(i)
Timer1.Stop()
TabControl1.TabPages.Add(i)
'rsts.Item(i).Body
'rsts.Item(i).SenderName
Next
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
myThread()
End Sub
带味精盒
没有 MSGBox + 调试