-1

私は現在、テスト中に完全に動作するように見えた Outlook アプリケーションを開発しています。

このコードMSGBox("ASDFG")は、 が所定の位置にある ( をrsts.Count返す1) 場合に機能するように見えますが、削除されるとすぐに、ステートメントは を返します0。's を追加しDebug.Printて違いが生じるかどうかを確認することで、これを超えようとしましたが、 が配置されている場合にのみコードが正しく実行されることがわかりMSGBoxました。

Timer10 が返された場合にスクリプトを毎秒再実行する間隔も追加しました。

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 あり

MSGBox あり


MSGBox + デバッグなし

MSGBox なし

4

1 に答える 1