tags:

views:

26

answers:

2

i have such code

For Each objItem In StartFolder.Items                    
    MessageBox.Show("to " + objItem.To)
Next

if field to is empty(empty in letter of outlook), there is no exception but the debugger shows

  objItem.To  Run-time exception thrown : System.MissingMemberException - Public member 'To' on type 'ReportItem' not found.  

how can i catch this? because any try to check property objItem.To will generate another exception

A: 

Can you do a try...catch to specifically catch the System.MissingMemberException?

winwaed
+3  A: 

Not knowing exactly what you are trying to do: You could test each item's type before attempting to access a property that does not exist for a particular type (in your post the item type in question is ReportItem).e.g.

For Each objItem In StartFolder.Items 
    '' I think you will need to fully qualify ReportItem with the full namespace...   
    if TypeOf obItem is ReportItem           
        MessageBox.Show("to " + objItem.To) 
Next 
Mitch Wheat
guess you're right, but how? any axample?
kusanagi
not exactly, look- i make loop in letters, some letters for example has field TO filled , so calling objItem.To works, but some letters don't have filled property TO , but this becaume knowing only when i try to access objItem.To, so i need somehow check property To
kusanagi