locked
Contact or Inbox RRS feed

  • Question

  • Hello

    how do i know if the selected items are in the inbox or in the contact area - is there an easy way?

    Thank you

    Martin

    Wednesday, March 21, 2018 10:06 AM

Answers

  • Hi krugi,

    You can try to refer example below and based on item you can know where it is selected.

    Sub GetSelectedItems()
     Dim myOlExp As Outlook.Explorer
     Dim myOlSel As Outlook.Selection
     Dim mySender As Outlook.AddressEntry
     Dim oMail As Outlook.MailItem
     Dim oAppt As Outlook.AppointmentItem
     Dim oPA As Outlook.PropertyAccessor
     Dim strSenderID As String
     Const PR_SENT_REPRESENTING_ENTRYID As String = _
     "http://schemas.microsoft.com/mapi/proptag/0x00410102"
     Dim MsgTxt As String
     Dim x As Long
    
        MsgTxt = "Senders of selected items:"
        Set myOlExp = Application.ActiveExplorer
        Set myOlSel = myOlExp.Selection
        
             For x = 1 To myOlSel.Count
                 If myOlSel.item(x).Class = OlObjectClass.olMail Then
                    MsgBox ("Mail Item")
                 ElseIf myOlSel.item(x).Class = OlObjectClass.olContact Then
                    MsgBox ("Contact Item")
                 ElseIf myOlSel.item(x).Class = OlObjectClass.olAppointment Then
                    MsgBox ("Appointment Item")
                 Else
                    MsgBox ("Other Item")
                 End If
             Next x
    
    End Sub
    

    Reference:

    Selection.Item Method (Outlook)

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 22, 2018 7:27 AM

All replies

  • Check the MessageClass property and/or the object type (MailItem, ContactItem, etc.)


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, March 21, 2018 5:24 PM
  • Hi krugi,

    You can try to refer example below and based on item you can know where it is selected.

    Sub GetSelectedItems()
     Dim myOlExp As Outlook.Explorer
     Dim myOlSel As Outlook.Selection
     Dim mySender As Outlook.AddressEntry
     Dim oMail As Outlook.MailItem
     Dim oAppt As Outlook.AppointmentItem
     Dim oPA As Outlook.PropertyAccessor
     Dim strSenderID As String
     Const PR_SENT_REPRESENTING_ENTRYID As String = _
     "http://schemas.microsoft.com/mapi/proptag/0x00410102"
     Dim MsgTxt As String
     Dim x As Long
    
        MsgTxt = "Senders of selected items:"
        Set myOlExp = Application.ActiveExplorer
        Set myOlSel = myOlExp.Selection
        
             For x = 1 To myOlSel.Count
                 If myOlSel.item(x).Class = OlObjectClass.olMail Then
                    MsgBox ("Mail Item")
                 ElseIf myOlSel.item(x).Class = OlObjectClass.olContact Then
                    MsgBox ("Contact Item")
                 ElseIf myOlSel.item(x).Class = OlObjectClass.olAppointment Then
                    MsgBox ("Appointment Item")
                 Else
                    MsgBox ("Other Item")
                 End If
             Next x
    
    End Sub
    

    Reference:

    Selection.Item Method (Outlook)

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 22, 2018 7:27 AM