我需要在转发邮件之前删除一些文本,每次执行此操作时都会丢失格式。请参阅下面的代码。
Sub RemoveExpression()
Dim Insp As Inspector
Dim obj As Object
Dim subStr As String
Dim oMail As MailItem
Dim itmOld As MailItem, itmNew As MailItem
Set Insp = Application.ActiveInspector
Set oMail = Insp.CurrentItem
lPosition = InStr(oMail.Body, "Subject: ") - 1
' obj.Subject = Mid(oMail.Subject, 5)
subStr = Left(oMail.Body, lPosition)
oMail.Body = Replace(oMail.Body, subStr, "")
oMail.Subject = Replace(oMail.Subject, "FW:", "")
'obj.Body = Replace(obj.HTMLBody, "abc", "")
Set obj = Nothing
Set Insp = Nothing
End Sub
如何保持格式化并删除文本?
答案 0 :(得分:1)
您正在使用纯文本Body
属性。您需要阅读并设置HTMLBody
属性。