0

現在、私が行っているダーティなPST取り込み作業の一部を自動化するためにVBScriptに取り組んでいますが、Outlook 2003から2007にアップグレードした後、何か問題があることがわかりました。

(OL2003のRTF本文の問題を回避するためにアップグレードする必要がありました..)

OutlookにPSTストアを閉じ、ログオフしてからオブジェクトを破棄するように指示した後でも(objNS = Nothingなどに設定)、使用しているPSTファイルのサイズに応じてOutlookは1〜30秒間ハングします。 。

簡単に回避して遅延を入れることができますが(Wscript.Sleep(300))、これは汚いので完全には信用できません... Outlookを適切に閉じる方法について何かアイデアはありますか?

GetObject()を使用してインスタンスのポーリングも試みましたが、タスクマネージャーにOUTLOOK.EXEが表示されている場合でも、Falseが返されるようです。

私が使用しているコードは以下のとおりです。

Function TestPSTInOutlook(strFileName)
' Open PST in Outlook then closes it, primarily to determine
' if Outlook has any difficulty in processing the PST in the
' first place.  Not interested in corruptions per message, just
' PST-wide (and passwords).

    Const olMailItem = 0
    Const olMSG = 3
    Const olDiscard = 1

    On Error Resume Next
    Dim objOL       ' Outlook.Application   
    Dim objNS       ' Outlook.Namespace
    Dim objFolder   ' Outlook.MAPIFolder
    Dim objIS       ' Outlook.Inspector 
    Dim objMail     ' Outlook.MailItem

    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")

    objNS.Logon
    objNS.AddStore strFileName

    If Err.Number <> 0 Then
        loggit_silent = True
        loggit("TestPSTInOutlook(): failed to open " & strFileName & " for reason: " & Err.Description)
        loggit_silent = False
        TestPSTInOutlook = False
    Else
        Set objFolder = objNS.Folders.GetLast
        objFolder.Name = strFileName

        Set objMail = objOL.CreateItem(olMailItem) 
        Set objIS = objMail.GetInspector 

        objIS.Close (olDiscard) 
        objMail.Close (olDiscard)

        objNS.RemoveStore objFolder
        loggit_silent = True
        loggit("TestPSTInOutlook(): success opening " & strFileName)
        loggit_silent = False
        TestPSTInOutlook = True
    End If

' BUG: Outlook 2007 refuses to shut down when told and takes its time - we have to wait otherwise we error  on trying to move the next PST file ...
' Does not exist in OL2003 but if we roll back then we don't get fixed Unicode PST support and degraded  ingestion performance
' 

    objNS.Logoff 
    objOL.Session.Logoff 
    objOL.Quit 

    Set objIS = Nothing 
    Set objMail = Nothing 
    Set objNS = Nothing 
    Set objOL = Nothing 

    Wscript.sleep(300)
End Function

注意:loggit()は純粋にロギング関数です(stdoutおよびdebuglog.txtに送信されます)

4

1 に答える 1