我已使用此代码在新窗口中打开所选消息:
Dim olApp As Outlook.Application
Dim Msg As Object设置olApp = Outlook.Application
设置Msg = olApp.ActiveExplorer.Selection.Item(1)
Msg.Display
我现在想去身体并在体内选择“ERROR”文字,然后留待手工治疗。
我实际上知道这个文本出现的行号(有更多的代码)。但我的问题是如何到达消息正文,转到行,选择文本 - 然后离开例程。
答案 0 :(得分:0)
尝试使用Word。未经测试的代码
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