The message.GetLast()
method gets the last item from a collection (Folder.Items
). Instead, you need to get an Explorer instance by calling the ActiveExplorer method of the Outlook Application
class which returns the topmost Explorer
object on the desktop. Use this method to return the Explorer
object that the user is most likely viewing. Then you may get the selected items in the Explorer window by getting the Selection
object (see the corresponding property of the Explorer
class), for example, the following VBA sample shows how to get selected items:
Sub GetSelectedItems()
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
Dim x As Integer
MsgTxt = "You have selected items from: "
Set myOlExp = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & ";"
Next x
MsgBox MsgTxt
End Sub
The Outlook object model is common for all programming languages, so you could easily find the required properties and methods that should be used.
Also you may find the Explorer.ActiveInlineResponse property which returns an item object representing the active inline response item in the explorer reading pane. This property returns null
if no inline response is visible in the Reading Pane.