在特定文件夹中保存已发送项目的副本 [英] Save Copy of Sent Item in a specific folder

查看:52
本文介绍了在特定文件夹中保存已发送项目的副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在特定文件夹中保存已发送邮件项目的副本.

I want to save a copy of a sent mail item in a specific folder.

点击发送"时会触发以下代码.

The below code is fired when hitting "send".

该项目作为未发送的电子邮件项目保存在文件夹中(Outlook 显示消息:此消息尚未发送").我希望将其保存为已发送项目(就像文件夹已​​发送项目"一样).

The item is saved in the folder as an unsent email item (Outlook shows the message: "This message has not been sent"). I want it saved as a sent item (just like the folder "sent items").

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
On Error GoTo ErrorHandler

Dim moveToFolder As Outlook.MAPIFolder
Dim myCopiedItem As Outlook.MailItem
    
Set ns = Application.GetNamespace("MAPI")
Set moveToFolder = ns.Folders("Mailbox - My Mailbox").Folders(".Waiting_for")

With Item

    If InStr(Item.Body, "/wf") > 0 Then
        Set myCopiedItem = Item.copy
        myCopiedItem.Move moveToFolder
    Else
    End If

End With

Exit Sub
ErrorHandler:
    MsgBox "Error!"
End Sub

推荐答案

当 ItemSend 事件触发时,消息尚未提交(您可以将 Cancel 参数设置为 true).您最早可以看到处于已发送状态的消息是在已发送邮件"文件夹上触发 Items.ItemAdd 事件时.

When ItemSend event fires, the message has not been submitted yet (you can set the Cancel parameter to true). The earliest you can see the message in the sent state is when the Items.ItemAdd event fires on the Sent Items folder.

为什么不简单地设置 MailItem.SaveSentMessageFolder 属性?Outlook 将在邮件发送后自动移动邮件.唯一的限制是该文件夹必须位于创建消息的同一存储区中.

Why not simply set the MailItem.SaveSentMessageFolder property? Outlook will automatically move the message after it is sent. The only limitation is that the folder must be in the same store where the message was created.

这篇关于在特定文件夹中保存已发送项目的副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆