1

「メールが到着する前に」でLotusscriptエージェントを実行しています。件名の「#」記号の後のテキストを取得するために必要です。件名フィールド(Evaluate、getFirstItem、getItemValueなど)をどのように取得しようとしても、常にエラーが発生します。通常、タイプの不一致またはオブジェクト変数が設定されていません。

以下のコードは私の現在のコードであり、14行目の「タイプの不一致」にエラー13を返します。

Option Public
Option Declare

Sub Initialize
    On Error GoTo ErrorHandler 
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim nextdoc As NotesDocument
    Dim result As String
    Set db = s.CurrentDatabase
    Set view = db.Unprocesseddocuments
    If Not view Is Nothing Then
        Set doc = view.Getfirstdocument()
        While Not doc Is Nothing
            result = Evaluate ("@Right(Subject;""#"")", doc)
            Print result
            Set nextDoc = view.GetNextDocument(doc)
            Call doc.Remove(True)
            Set doc = nextDoc
        Wend
    End If
    Print "End"
Done: 
    Exit Sub
ErrorHandler: 
    Select Case Err 
        Case Else 
            Print "Error " & CStr(Err) & " in agent on line " & CStr(Erl) & ": " & Error 
            Resume Done 
    End Select 
End Sub 
4

2 に答える 2

4

新着メールが到着する前に、NotesDocumentCollectionは返されません。使用する...

Sub Initialize
    Dim Session As New NotesSession
    Dim Doc As NotesDocument
    Dim result As String
    Set Doc = Session.DocumentContext
    Let result = StrRight(Doc.Subject(0), "#")
End Sub

UnprocessedDocumentsの代わりに...

于 2012-03-09T15:16:22.063 に答える
3

Evaluateを使用する場合の元の質問を参照して、Type Mismatch「Evaluateステートメントの使用」の下にあるDesignerのヘルプに注意してください。

" returnValueは、要素のタイプと数が数式の結果を反映する配列です。スカラー値が配列の要素0に返されます。要素の数がわからない場合があるため、戻り値にはバリアントを使用する必要があります。戻ってきた。"

したがって、次の変更を試してください。

    ...
    Dim result As Variant
    ...
    result = Evaluate (|@Right(Subject;"#")|, doc)
    ' Treat result as an array
    Print result(0)
    ...
于 2012-03-11T22:25:23.920 に答える