问题
This question looks like it should have been answered here: Outlook VBA Save Copy Sent Item
I am unable to find the referenced "Items.ItemAdd" event amongst the list of events in the VB Editor for Outlook 2016.
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.
I can't use "MailItem.SaveSentMessageFolder" as I am trying to move the sent mail to a PST.
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.
回答1:
Work with Items.ItemAdd Event (Outlook)
Example
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
来源:https://stackoverflow.com/questions/48496150/how-do-i-use-itemadd-on-the-sent-items-folder