跳到主要內容

在Outlook中發送電子郵件時如何自動創建任務?

有時,在Outlook中發送電子郵件時,可能需要自動創建電子郵件任務。 在這裡,我們為您提供一種快速完成它的方法。

在帶有VBA的Outlook中發送電子郵件時自動創建任務


在帶有VBA的Outlook中發送電子郵件時自動創建任務

使用下面的VBA代碼,您可以基於Outlook中的發送電子郵件自動創建任務。 請執行以下操作。

1.啟動Outlook,按 其他 + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

2。 在裡面 Microsoft Visual Basic for Applications 窗口中,將下面的VBA代碼複製到 本次展望會議 代碼窗口。

VBA代碼:在Outlook中發送電子郵件時自動創建任務

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by Extendoffice 20181123
    Dim xYesNo As Integer
    Dim xPrompt As String
    Dim xTaskItem As TaskItem
    Dim xRecipient As String
    On Error Resume Next
    xPrompt = "Do you want to create a task for this message?"
    xYesNo = MsgBox(xPrompt, vbYesNo + vbInformation, "Kutools for Outlook")
    Cancel = False
    If xYesNo = vbNo Then Exit Sub
    Set xTaskItem = Application.CreateItem(olTaskItem)
    For Each Rcp In Item.Recipients
        If xRecipient = "" Then
            xRecipient = Rcp.Address
        Else
            xRecipient = xRecipient & vbCrLf & Rcp.Address
        End If
    Next Rcp
    xRecipient = xRecipient & vbCrLf & Item.Body
    With xTaskItem
        .Subject = Item.Subject
        .StartDate = Item.ReceivedTime
        .DueDate = Date + 3 + CDate("9:00:00 AM")
        .ReminderSet = True
        .ReminderTime = Date + 2 + CDate("9:00:00 AM")
        .Body = xRecipient
        .Save
    End With
    Set xTaskItem = Nothing
End Sub

備註:郵件收件人和郵件正文將自動添加到任務正文中。 任務的開始日期是消息的發送日期,任務將在3天內到期。 一天后的9點,您會被提醒執行該任務。 您可以根據需要更改它們。

3.保存代碼,然後按 其他 + Q 鍵以關閉“ Microsoft Visual Basic應用程序”窗口。

4.從現在開始,單擊 送出 在新的或已回复的電子郵件窗口中, 創建任務 彈出對話框如下圖所示,點擊 發送電子郵件並自動創建任務,或單擊 沒有 發送電子郵件而不創建任務。


最佳辦公生產力工具

Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook

🤖 人工智慧郵件助手: 具備人工智慧魔力的即時專業電子郵件——一鍵天才回覆、完美語調、多語言掌握。輕鬆改變電子郵件! ……

📧 電子郵件自動化: 外出(適用於 POP 和 IMAP)  /  安排發送電子郵件  /  發送電子郵件時按規則自動抄送/密件副本  /  自動轉送(進階規則)   /  自動添加問候語   /  自動將多收件者電子郵件拆分為單獨的訊息 ...

📨 電子郵件管理: 輕鬆回憶電子郵件  /  按主題和其他人阻止詐騙電子郵件  /  刪除重複的電子郵件  /  進階搜索  /  合併資料夾 ...

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

🌟 介面魔法: 😊更多又漂亮又酷的表情符號   /  使用選項卡式視圖提高 Outlook 工作效率  /  最小化 Outlook 而不是關閉 ...

👍 一鍵奇蹟: 使用傳入附件回覆全部  /   反網路釣魚電子郵件  /  🕘顯示寄件者的時區 ...

👩🏼‍🤝‍👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人  /  將聯絡人群組拆分為各組  /  刪除生日提醒 ...

超過 100特點 等待您的探索! 按此處了解更多。

閱讀更多       免費下載      購買
 

 

Comments (3)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
HI,

This worked for a few days and now it no longer works.

Is there a reason?
This comment was minimized by the moderator on the site
Hi Terri Amos,
Please enable the Enable all macros option and the Apply macro security settings to installed add-ins option as shown in the screenshot below. After that, restart your Outlook.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/task.png
This comment was minimized by the moderator on the site
Is there a way to modify this as to include more of a link to the sent mail than just recipients & subject? ie. add the sent mail as attachment?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations