Vba 在Outlook 2010中查找电子邮件中的文本并删除此文本之后的所有文本

Vba 在Outlook 2010中查找电子邮件中的文本并删除此文本之后的所有文本,vba,outlook,outlook-2010,Vba,Outlook,Outlook 2010,我正在尝试在电子邮件中查找文本,并在这一点之后删除所有文本。 我已经设法在Word 2010中获得一个工作宏,但是我无法在Outlook中复制类似的内容 始终会有一个特定的文本标题“文本”,然后在此之后的一些文本,每个电子邮件都会有所不同 我在word中使用的宏:这是从 有关如何在Outlook 2010中实现类似功能的任何建议?首先打开邮件项目,然后尝试此未经测试的代码 Option Explicit Sub DeleteAfterText() ' Deletes all text aft

我正在尝试在电子邮件中查找文本,并在这一点之后删除所有文本。 我已经设法在Word 2010中获得一个工作宏,但是我无法在Outlook中复制类似的内容

始终会有一个特定的文本标题“文本”,然后在此之后的一些文本,每个电子邮件都会有所不同

我在word中使用的宏:这是从


有关如何在Outlook 2010中实现类似功能的任何建议?

首先打开邮件项目,然后尝试此未经测试的代码

Option Explicit

Sub DeleteAfterText()

' Deletes all text after endStr.

Dim currMail As mailitem
Dim msgStr As String

Dim endStr As String
Dim endStrStart As Long
Dim endStrLen As Long

Set currMail = ActiveInspector.CurrentItem
endStr = "Text"
endStrLen = Len(endStr)

msgStr = currMail.HTMLBody
endStrStart = InStr(msgStr, endStr)

If endStrStart > 0 Then
    currMail.HTMLBody = Left(msgStr, endStrStart + endStrLen)
End If

End Sub
Option Explicit

Sub DeleteAfterText()

' Deletes all text after endStr.

Dim currMail As mailitem
Dim msgStr As String

Dim endStr As String
Dim endStrStart As Long
Dim endStrLen As Long

Set currMail = ActiveInspector.CurrentItem
endStr = "Text"
endStrLen = Len(endStr)

msgStr = currMail.HTMLBody
endStrStart = InStr(msgStr, endStr)

If endStrStart > 0 Then
    currMail.HTMLBody = Left(msgStr, endStrStart + endStrLen)
End If

End Sub