跳到主要內容

如何在Outlook中自動突出顯示來自傳入電子郵件的特定關鍵字

在Outlook中,您每天可能會收到成千上萬的電子郵件,您是否曾經想過自動從收到的電子郵件中突出顯示某些特定的關鍵字? 在本文中,我介紹了一個VBA代碼,以自動突出顯示您從Outlook中的傳入電子郵件中指定的關鍵字。

自動突出顯示來自傳入電子郵件的關鍵字


自動突出顯示來自傳入電子郵件的關鍵字

除了VBA,Outlook中沒有內置函數可以處理此作業。

1。 按 Alt + F11鍵 啟用 Microsoft Visual Basic for Applications 窗口。

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