将段落中断更改为换行符

时间:2016-04-14 18:33:02

标签: vba outlook

在发送电子邮件之前,我想将分段符更改为换行符。而不是使用替换,我想运行一个宏。放置在ThisOutlookSession中的以下内容不会保存为宏。我假设因为你不能传递参数???但是我在哪里放置代码?

Private Sub ChgParagraphsToLineBreaks(ByVal Item As Object, Cancel As Boolean)
    Item.Body = Replace(Item.Body, "^p", "^l")
End Sub

1 个答案:

答案 0 :(得分:0)

必须在发送电子邮件时触发的Application.ItemSend()事件中调用您的sub。您也可以在此活动中取消发送。

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    ChgParagraphsToLineBreaks Item

End Sub

Private Sub ChgParagraphsToLineBreaks(ByVal Item As Object)
    dim strBody as string
    strBody = Item.Body
    strBody = Replace(strBody, "^p", "^l")
    Item.Body = strBody
End Sub