none
X is not a member og 'MailItem'??? RRS feed

  • Question

  • Hi

    If I debug a mailitem, i can see a path like...

    mymailitem
        |
        |-- Parent
                 |
                 |-- Folders
                          |
                          |-- Session
                                   |
                                   |-- ExchangeMailboxServerName

    And this "ExchangeMailboxServerName" has a value in debug.

    But if I enter this in the "Watch"...

    mymailitem.Parent.Foldes.Session.ExchangeMailboxServerName

    ... then I get the error "Parent is not a member of MailItem"

    What am I doing wrong? How come I can exapand the mymailitem object in the watch window like above, but I can't enter the fill path at above?

    Thanks

    Friday, March 4, 2016 8:39 AM

Answers

All replies

  • Hello MOJO,

    First of all, I have noticed that you didn't type the full path correctly:

    mymailitem.Parent.Foldes.Session.ExchangeMailboxServerName

    There is no Foldes property defined for the parent object. 

    Moreover, the Parent property of the MailItem class returns the parent Object of the specified object. You need to cast it to the appropriate type before accessing any properties or methods. 

    I'd recommend using any property explorer such as OutlookSpy or MFCMAPI (open-source) for observing property values in Outlook.

    Where does the mail item object come from? Did you check out the MessageClass property value of the Outlook item? Are you sure it is a mail item? 

    Friday, March 4, 2016 10:27 AM
  • MailItem.Parent returns a generic object (IDispatch). You need to cast it to the MAPIFolder interface.

    What exactly are you trying to retrieve and why?


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

    Friday, March 4, 2016 1:38 PM