outlook-open-selected-mail-items

Outlook - Open Selected Mail Items

This macro opens a mail item selection.

Outlook

  • 10566
  • 1825
  • 3
  • 0
Add to collection
© 2024VBAmacros.net

1 Open MS Outlook.


2 Go to Developer's tab > click on "Visual Basic" button or hit Alt + F11.


3 Go to Insert tab > click on "Module" or hit M.


4 Copy the VBA code from below.

5 Paste the code in the newly created module.


6 Go to Run tab > click on "Run Sub/UserForm" or hit F5.


7 That's it!


Advertisement

Code
'==========================================
' Open Selected Mail Items
'==========================================
Sub openSelectedMailItems()
    ' Set variables
    Dim item As Outlook.MailItem
    Dim sct As Outlook.Selection
    Dim byt As Byte
    ' Get selected items
    Set sct = Application.ActiveExplorer.Selection
    ' Check if any items were selected
    If sct.Count > 0 Then
        ' Loop through selected items
        For byt = 1 To sct.Count
            ' Set mail item
            Set item = sct(byt)
            ' Open mail item
            item.Display
        Next byt
    Else
        ' Return message
        MsgBox "Please select any email!"
    End If
End Sub
Advertisement


Comments
Sort by:
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Advertisement
  • Created
    12-Jun-2020
  • Last updated
    12-Jun-2020
Advertisement
VBAmacros.net VBAmacros.net
Code was successfully copied!
VBAmacros.net VBAmacros.net
Please sign in!
VBAmacros.net VBAmacros.net
You've already voted!