如何在“已发送邮件"文件夹上使用ItemAdd? [英] How do I use ItemAdd on the Sent Items folder?
问题描述
这个问题似乎应该在这里回答: Outlook VBA保存副本已发送项目
This question looks like it should have been answered here: Outlook VBA Save Copy Sent Item
我无法在Outlook 2016的VB编辑器中的事件列表中找到引用的"Items.ItemAdd"事件.
I am unable to find the referenced "Items.ItemAdd" event amongst the list of events in the VB Editor for Outlook 2016.
Application.ItemSend位于"ThisOutLookSession"中.我提出的脚本看起来与原始问题中发布的脚本90%相似,但我也遇到了同样的问题.邮件已保存为发送前的状态.
Application.ItemSend is located in "ThisOutLookSession". The script I came up with looks 90% similar to the one posted in the original question and I have the same problem. The mail item is saved in it's pre-send condition.
我无法使用"MailItem.SaveSentMessageFolder",因为我正尝试将已发送的邮件移至PST.
I can't use "MailItem.SaveSentMessageFolder" as I am trying to move the sent mail to a PST.
此事件的解释如下: https://msdn.microsoft. com/zh-CN/vba/outlook-vba/articles/items-itemadd-event-outlook
The Event is explained here: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/items-itemadd-event-outlook
万一有人问为什么不使用自动存档功能?",我的组织为已发送邮件"和自动存档"设置了一些糟糕的组策略.我无所适从,无法设置已发送邮件的自动存档.
In case someone asks "Why not use the AutoArchive Function?", my organization has some terrible group policies set up for both Sent Items and AutoArchive. I can't wade through the mess to get AutoArchive for sent items set up.
推荐答案
使用 示例
Option Explicit
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olNs As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Set olNs = Application.GetNamespace("MAPI")
Set Inbox = olNs.GetDefaultFolder(olFolderSentMail)
Set Items = Inbox.Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.mailitem Then
' code to copy the sent Item here
End If
End Sub
这篇关于如何在“已发送邮件"文件夹上使用ItemAdd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!