我已使用此代码在新窗口中打开所选消息:
Dim olApp 作为 Outlook.Application
将消息调暗为对象 设置 olApp = Outlook.Application 设置 Msg = olApp.ActiveExplorer.Selection.Item(1) 消息显示
我现在想去body里面选择body里面的文字“ERROR”,然后留待人工处理。
我实际上知道此文本出现的行号(还有更多代码)。但我的问题是如何到达邮件正文,转到行,选择文本 - 然后离开例程。
尝试使用 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