Skip to main content
Author: Xiaoyang Last Modified: 2025-08-06

在 Outlook 中,我們可能很容易從電子郵件創建新任務。但是,您是否嘗試過在收到特定郵件時自動創建新任務呢?例如,我只想從老闆的郵件中自動創建任務。您該如何在 Outlook 中處理這個工作呢?

使用 VBA 程式碼在 Outlook 中接收指定郵件時自動創建新任務


使用 VBA 程式碼在 Outlook 中接收指定郵件時自動創建新任務

這項工作沒有直接的方法或規則可以解決,但在此,我可以將 VBA 程式碼和規則結合起來完成它。請按照以下步驟操作:

1. 啟動 Outlook,然後按住「ALT + F11」鍵以打開「Microsoft Visual Basic for Applications」窗口。

2. 在「Microsoft Visual Basic for Applications」窗口中,從「Project1 (VbaProject.OTM)」窗格雙擊「ThisOutlookSession」以打開程式碼窗口,然後複製並將以下程式碼粘貼到空白模塊中。

VBA 程式碼:在接收郵件時自動創建新任務:

Sub CreateNewTask(Item As Outlook.MailItem)
Dim xNewTask As TaskItem
On Error Resume Next
Set xNewTask = Outlook.CreateItem(olTaskItem)
With xNewTask
    .Subject = Item.Subject
    .StartDate = Item.ReceivedTime
    .DueDate = Item.ReceivedTime + 1
    .Body = Item.Body
    .Importance = olImportanceHigh
    .Save
End With
Set xNewTask = Nothing
End Sub
the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 1

3. 然後保存並關閉程式碼。插入程式碼後,您需要創建一個規則。請點擊「Home」選項卡下的「Rules」>「Manage Rules & Alerts」。請參見截圖:

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 2

4. 在「Rules and Alerts」對話框中,點擊「New Rule」。請參見截圖:

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 3

5. 在彈出的「Rules Wizard」中,從「Start from a blank rule」部分選擇「Apply rule on messages I receive」。請參見截圖:

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 4

6. 點擊「Next」按鈕。在「Step 1: Select condition(s)」列表框中,選擇您要創建的條件。在本例中,我將勾選「from people or public group」選項。然後在「Step 2: Edit the rule description (click an underlined value)」部分,點擊「people or public group」鏈接以打開「Rule Address」對話框,並雙擊您想自動創建任務的郵件地址。請參見截圖:

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 5

7. 點擊「OK」,然後繼續點擊「Next」。在「Step 1: Select action(s)」列表框中,勾選「run a script」。然後在「Step 2: Edit the rule description (click an underlined value)」部分,點擊「a script」鏈接。將彈出「Select Script」對話框;選擇先前添加的宏並點擊「OK」。

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 6

8. 然後點擊「Next」>「Next」進入「Finish」規則設置屏幕。在「Step 1: Specify a name for this rule」文本框中輸入規則名稱,然後在「Step 2: Setup rule options」部分勾選「Turn on this rule」。請參見截圖:

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 7

9. 然後點擊「Finish」按鈕和「OK」以關閉「Rules and Alerts」對話框。

10. 從現在開始,一旦您收到來自特定地址的郵件,Outlook 將自動創建相應的任務。您可以在您的任務文件夾中檢查這些任務。請參見截圖:

the screenshot of step about auto creating new tasks when receiving specified emails in Outlook 8

最佳 Office 生產力工具

最新消息:Kutools for Outlook 推出免費版本!

體驗全新 Kutools for Outlook,擁有100+ 強大功能!立即下載!

🤖 Kutools AI 運用先進 AI 技術,輕鬆處理郵件,包括答覆、摘要、優化、擴寫、翻譯與撰寫郵件。

📧 郵件自動化自動回覆(支援 POP 和 IMAP) / 計劃發送郵件 / 發送郵件時根據規則自動抄送密送 / 自動轉發(高級規則) / 自動新增問候語 / 自動將多收件人郵件分割為個別郵件 ...

📨 郵件管理撤回郵件 /依主題等條件阻擋詐騙郵件 / 刪除重複郵件 / 高級搜索 / 整合文件夾 ...

📁 附件專業版批次保存 / 批次拆離 / 批次壓縮 / 自動保存 / 自動拆離 / 自動壓縮 ...

🌟 介面魔法😊更多精美酷炫表情符號 /重要郵件來臨提醒 / 最小化 Outlook 而非關閉 ...

👍 一鍵神技帶附件全部答復 /反釣魚郵件 / 🕘顯示發件人時區 ...

👩🏼‍🤝‍👩🏻 聯絡人與日曆批次從選中郵件新增聯絡人 / 將聯絡人組分割為多個組 / 移除生日提醒 ...

以您偏好的語言使用 Kutools —— 支援英語、西班牙語、德語、法語、中文及40 多種其他語言!

只需一鍵即可立即啟用 Kutools for Outlook。立即下載,提升您的效率!

kutools for outlook features1 kutools for outlook features2