简体   繁体   English

如何在 Outlook 2010 VBA 中编写的电子邮件中进行搜索和替换

[英]How do search & replace in email being composed in Outlook 2010 VBA

I'm am trying to write some VBA search and replace paragraph marks to manual line breaks in an email I'm composing.我正在尝试编写一些 VBA 搜索并将段落标记替换为我正在撰写的电子邮件中的手动换行符。

Although I write VBA in Excel, I'm a newcomer to Outlook 2012 VBA.虽然我用 Excel 编写 VBA,但我是 Outlook 2012 VBA 的新手。

I'm starting with this code我从这个代码开始

tmp = Split(mail.HTMLBody, vbCrLf)
For Each Line In tmp
    If Line <> "" Then
        newBody = newBody  & Line & vbCrLf
    End If
Next
mail.HTMLBody = newBody

which came from VBA Outlook - Replace Paragraph Mark With Manual Line Break .来自VBA Outlook - 用手动换行符替换段落标记

I tried changing "mail" to "item.htmlbody" but I'm getting an "Object Required" error.我尝试将“邮件”更改为“item.htmlbody”,但出现“需要对象”错误。

Can someone set me on the right path with this?有人可以用这个让我走上正确的道路吗?

Before processing the current item在处理当前项目之前

Set mail = ActiveInspector.CurrentItem设置邮件 = ActiveInspector.CurrentItem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM