跳到主要内容

在Outlook中发送电子邮件时如何自动创建任务?

有时,在Outlook中发送电子邮件时,可能需要自动创建电子邮件任务。 在这里,我们为您提供一种快速完成它的方法。

在带有VBA的Outlook中发送电子邮件时自动创建任务


在带有VBA的Outlook中发送电子邮件时自动创建任务

使用下面的VBA代码,您可以基于Outlook中的发送电子邮件自动创建任务。 请执行以下操作。

1.启动Outlook,按 其他 + F11 键打开 Microsoft Visual Basic应用程序 窗口。

2.在 Microsoft Visual Basic应用程序 窗口,将下面的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