我正在尝试替换传入电子邮件中的某些文本。
我找到了几个脚本,但这些脚本用于发送/创建电子邮件。
当前工作代码(感谢拉里):
Sub testing(MyMail As MailItem)
MyMail.HTMLBody = Replace(MyMail.HTMLBody, "TESTING", "TESTINGTESTING")
MyMail.Save
End Sub
此 Outlook 会话代码:
Private Sub Application_NewMail()
Dim mail As MailItem
Set mail = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items.GetFirst
If mail.Class = olMail Then 'It should be
'change subject
mail.Subject = "TESTING"
'replace body text
If mail.BodyFormat = olFormatHTML Then
mail.HTMLBody = Replace(mail.HTMLBody, "TESTING", "TESTINGTESTING")
Else
mail.Body = Replace(mail.Body, "SEARCHTEXT", "REPLACETEXT")
End If
End If
End Sub