【问题标题】:Convert incoming mail to plain text将收到的邮件转换为纯文本
【发布时间】:2020-12-20 22:35:38
【问题描述】:

我想将 Outlook 中收到的 HTML 邮件转换为“纯文本”并转发电子邮件。

我尝试了几个代码示例。

Sub ConvertToPlain(MyMail As MailItem)
    Dim strID As String
    Dim objMail As Outlook.MailItem
        
    strID = MyMail.EntryID
    Set objMail = Application.Session.GetItemFromID(strID)
    objMail.BodyFormat = olFormatPlain
    objMail.Save
     
    Set objMail = Nothing
End Sub

【问题讨论】:

  • 纯文本是什么意思?您想要电子邮件的原始 HTML 吗?
  • 我想删除电子邮件的任何格式。我相信 objMail.BodyFormat = olFormatPlain 解决了这个问题,但上面的代码对我不起作用。
  • 收到的邮件是什么格式。 ?

标签: vba outlook


【解决方案1】:

您可以只创建一个新邮件项,然后设置.body 属性。阅读邮件项目的.body 只会获得文本,没有任何格式(与阅读.HTMLBody 不同,后者会获得完整的HTML)。

这是一个 sub 示例,它将将电子邮件的未格式化文本发送到您指定的任何地址

Sub sendPlainText(MyMail As MailItem, sendTo As String)
    Dim newMail As Outlook.MailItem

    Set newMail = Application.CreateItem(olMailItem) 'Create a new email

    With newMail
        .To = sendTo 'Whoever you want to send the new mail item to
        .subject = MyMail.subject 'Copy subject of original email
        .Body = MyMail.Body 'Copy plain text of body to new mail item
        .send 'Send the new email
    End With
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 2011-09-28
    相关资源
    最近更新 更多