跳到主要内容

如何在Outlook中自动突出显示来自传入电子邮件的特定关键字

在Outlook中,您每天可能会收到成千上万的电子邮件,您是否曾经想过自动从收到的电子邮件中突出显示某些特定的关键字? 在本文中,我介绍了VBA代码以自动突出显示您从Outlook中的传入电子邮件中指定的关键字。

自动突出显示来自传入电子邮件的关键字


自动突出显示来自传入电子邮件的关键字

除了VBA,Outlook中没有内置函数可以处理此作业。

1。 按 Alt + F11键 启用 Microsoft Visual Basic应用程序 窗口。

2.然后双击 本次展望会议 在左边 项目 窗格,然后将下面的代码复制并粘贴到新的代码窗口中。

VBA:在电子邮件中自动突出显示关键字

Public WithEvents GMailItems As Outlook.Items
'UpdatebyExtendoffice20181106
Private Sub Application_Startup()
    Set GMailItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub GMailItems_ItemAdd(ByVal Item As Object)
    If Item.Class <> olMail Then Exit Sub
    AutoHighlight_SpecificWords Item
End Sub
Sub AutoHighlight_SpecificWords(Mail As Outlook.MailItem)
    Dim xWord As Variant
    Dim xHTMLBody As String, xStr As String
    Dim xWordArr
    On Error Resume Next
    xWordArr = Array("Kutools", "Important")  'keyword
    xHTMLBody = Mail.HTMLBody
    For Each xWord In xWordArr
        If InStr(xHTMLBody, xWord) > 0 Then
            xStr = "<font style=" & Chr(34) & "background-color: yellow" & Chr(34) & ">" & xWord & "</font>"
            xHTMLBody = Replace(xHTMLBody, xWord, xStr)
            Mail.HTMLBody = xHTMLBody
        End If
    Next
    Mail.Save
End Sub

提示: 在代码中,您可以根据需要在此脚本中更改关键字 xWordArr = Array(“库工具“”重要") .

3.然后保存代码并返回Outlook,在 主页 标签,点击 规则 > 管理规则和警报.
doc自动突出显示文本1

4.在 规则和警报 对话框中,单击 新规则 电子邮件规则 标签,然后在 规则向导 对话框中,单击 对我收到的消息应用规则.
doc自动突出显示文本2

5。 点击 下一页 > 下一页 > 转到第三个对话框,检查 运行脚本Step1 部分,然后单击 一个脚本 in Step2 启用部分 选择脚本 对话框中,选择此代码 Project1.ThisOutlookSession.AutoHighlight_SpecificWords。 点击 OK.
doc自动突出显示文本3 doc自动突出显示文本4

6。 点击 下一页 > 下一页,在最后一个对话框中,为此规则命名。
doc自动突出显示文本5

7。 点击 完成 > OK 完成规则。

从现在开始,您指定的关键字将在收到的电子邮件中自动突出显示。
doc自动突出显示文本6


将多个电子邮件保存或导出到Outlook中的其他fomat文件(PDF / HTML / WORD / EXCEL)

有时,您可能希望将电子邮件作为其他格式的文件(例如Outlook中的PDF,Word或Excel文件)保存或导出到文件夹。 在Outlook中,“另存为”和“导出”功能均不能处理此作业。 然而, Kutools for Outlook's Save as file 实用程序可以一次将多个电子邮件导出为多种格式的文件。    点击免费试用45天!
doc另存为文件
 
Kutools for Outlook:拥有数十个方便的 Outlook 插件,可在 45 天内免费试用,无任何限制。

最佳办公生产力工具

Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook

🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...

📧 电子邮件自动化: 外出(适用于 POP 和 IMAP)  /  安排发送电子邮件  /  发送电子邮件时按规则自动抄送/密件抄送  /  自动转发(高级规则)   /  自动添加问候语   /  自动将多收件人电子邮件拆分为单独的消息 ...

📨 电子邮件管理: 轻松回忆电子邮件  /  按主题和其他人阻止诈骗电子邮件  /  删除重复的电子邮件  /  高级搜索  /  合并文件夹 ...

📁 附件专业版批量保存  /  批量分离  /  批量压缩  /  自动保存   /  自动分离  /  自动压缩 ...

🌟 界面魔法: 😊更多又漂亮又酷的表情符号   /  使用选项卡式视图提高 Outlook 工作效率  /  最小化 Outlook 而不是关闭 ...

👍 一键奇迹: 使用传入附件回复全部  /   反网络钓鱼电子邮件  /  🕘显示发件人的时区 ...

👩🏼‍🤝‍👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人  /  将联系人组拆分为各个组  /  删除生日提醒 ...

超过 100特点 等待您的探索! 单击此处了解更多。

了解更多       免费下载      购买
 

 

Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I found a solution...

you need to enable Macros...and it WORKS (boom)

Outlook settings > Trust Center > Trust Center Settings > Macro Settings > "Enable all macros"
This comment was minimized by the moderator on the site
"run a script" is not showing, which I guess is an option not allowed by my employer
This comment was minimized by the moderator on the site
you should change register key please look https://www.slipstick.com/outlook/rules/outlook-run-a-script-rules/ but above process doesn't work for o365 outlook version on windows 10
This comment was minimized by the moderator on the site
Didn't work
This comment was minimized by the moderator on the site
didn't wok for o365 installed outlook on windows 10
This comment was minimized by the moderator on the site
doesn't work for o365 outlook version on windows 10 I applied everything
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations