2

このコードを使用して、選択したメッセージを新しいウィンドウで開きました。

Dim olApp As Outlook.Application

薄暗いメッセージをオブジェクトとして

olApp = Outlook.Application を設定します。

メッセージを設定 = olApp.ActiveExplorer.Selection.Item(1)

メッセージ表示

ここで、本文に移動して、本文内のテキスト「ERROR」を選択し、手動処理のために残します。

このテキストが表示される行番号を実際に知っています(さらにコードがあります)。しかし、私の問題は、メッセージの本文に移動し、行に移動し、テキストを選択して、ルーチンを終了する方法です。

4

1 に答える 1

1

ワードを使ってみてください。テストされていないコード

Sub SearchString()
Dim myInspector As Outlook.Inspector
Dim myObject As Object
Dim myItem As Outlook.MailItem
Dim myDoc As Word.Document

Dim strItem As String

Set myInspector = Application.ActiveInspector
Set myObject = myInspector.CurrentItem

'The active inspector is displaying a mail item.
If myObject.MessageClass = "IPM.Note" And _
    myInspector.IsWordMail = True Then
    Set myItem = myInspector.CurrentItem
    'Grab the body of the message using a Word Document object.
    Set myDoc = myInspector.WordEditor
    myDoc.Range.Find.ClearFormatting
    Set mySelection = myDoc.Application.Selection
    With mySelection.Find
        .Text = "ERROR"
    End With
    If mySelection.Find.Execute = False Then
       MsgBox "There is no ERROR in this message."
    End If
End If
End Sub

http://blogs.msdn.com/b/officedevdocs/archive/2011/03/15/how-to-search-for-a-string-in-an-email-message-and-automate-a-から適応文字列を含む返信.aspx

于 2013-10-26T13:37:57.283 に答える