问题
I have the code below in which the SenderName MailItem property appears blank.
Private Sub Application_ItemSend(ByVal MyItem As Object, Cancel As Boolean)
Dim res As Integer
' The "Class" MailItem property is found
If MyItem.Class = olMail Then
' This is coming up blank
' The "SenderName" MailItem property is not apparent
MsgBox MyItem.SenderName
res = MsgBox("Archive outgoing email?", vbQuestion + vbYesNo, "XYZ")
If res = vbYes Then
Call ProcessIt(MyItem)
Else
Cancel = True
End If
End If
End Sub
Some schoolboy error perhaps and will appreciate pointers as to what I am missing.
Outlook 2013 Windows 7
回答1:
Sender related properties are populated only after the message is actually sent and moved to the Sent Items folder. By the time Application.ItemSend event fires, the message is still unsent.
The earliest you can access the sent message with all the properties populated is in the Items.ItemAdd event on the Sent Itens folder.
来源:https://stackoverflow.com/questions/28698291/missing-outlook-mailitem-properties-in-application-itemsend