【问题标题】:How do I use ItemAdd on the Sent Items folder?如何在已发送邮件文件夹中使用 ItemAdd?
【发布时间】:2020-06-25 16:16:18
【问题描述】:

这个问题看起来应该在这里得到回答: Outlook VBA Save Copy Sent Item

我无法在 Outlook 2016 的 VB 编辑器的事件列表中找到引用的“Items.ItemAdd”事件。

Application.ItemSend 位于“ThisOutLookSession”中。我想出的脚本看起来与原始问题中发布的脚本有 90% 相似,我也遇到了同样的问题。邮件项目以发送前的状态保存。

我无法使用“MailItem.SaveSentMessageFolder”,因为我正在尝试将发送的邮件移动到 PST。

事件解释如下: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/items-itemadd-event-outlook

如果有人问“为什么不使用自动存档功能?”,我的组织为已发送邮件和自动存档设置了一些糟糕的组策略。我无法通过混乱来设置已发送项目的自动存档。

【问题讨论】:

  • 那么你的代码有什么问题?

标签: vba email outlook


【解决方案1】:

使用Items.ItemAdd Event (Outlook)

例子

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

【讨论】:

  • 谢谢!我错过了 object_ItemAdd 中 object_ 的点是用户提供的对象(因此 ItemAdd 是该对象可以附带的事件)。对不起,糟糕的解释。无论如何,谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-05
  • 2016-10-02
  • 2018-05-08
  • 2011-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多