如果这已经发布,请告诉我,因为我无法找到它:)
我在 Outlook 中提示选择当前邮件项目并在打开应用程序之前将其删除:
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set CurrentItem = objApp.ActiveExplorer.Selection.item(1)
Case "Inspector"
Set CurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Dim mailItem As Outlook.mailItem
Set mailItem = CurrentItem
Dim deleteItem As Boolean
deleteItem = objApp.mailItem.Delete
If MsgBox("Would you like to move this message to deleted items?", vbYesNo + vbQuestion, "File Indexing") _
= vbYes Then
mailItem = deleteItem
deleteItem = True
Else
deleteItem = False
End If
所有这些都完美无缺,但如果没有选择当前项目,我希望出现一个模式窗口,但我不确定如何添加它。它会在同一个 IfThen 中,还是在完全不同的语句中?我试过添加一些类似的东西
If CurrentItem = Null Then
MsgBox ("Please select a mail item")
End If
但随后 MsgBox 永远不会出现并且代码正常执行。感谢您的任何帮助!
编辑:感谢您的回复。不幸的是,我发现了一些与此无关的错误,因此我需要在向 Outlook 按钮添加其他代码之前解决它们。