Outlook VBA - Get Details Of Current Active (Or Open) Email

前端 未结 1 1107
我寻月下人不归
我寻月下人不归 2021-02-13 00:43

I am completely stuck as to how to retrieve details of an email which is either currently selected or open. In fact, I can\'t find any details on how to access an email. It se

相关标签:
1条回答
  • 2021-02-13 01:04

    To get the currently selected emails by looking at the Selection object of the Explorer.

    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    
    Set myOlExp = Application.ActiveExplorer
    Set myOlSel = myOlExp.Selection
    

    The selection object can contain many items and also contain Items that are of other types than mail (IPM.Note) i.e calendar apps etc. So if you only want mail items you can take a look at the item MessageClass

    As for the current email that is trickier as you can multuiple of these open if you just want the top most you can use the Application.ActiveInspector otherwise you should look at the Inspectors Collection of the Application object. You can then get the "item" from the CurrentItem property off the Inspector(remember these can be non mails as well)

    Hope full that will get you going

    0 讨论(0)
提交回复
热议问题