0

Firstly let me say this code is developed in SharpDevelop 4.3, the code runs ok and gives the results it is supposed to, however the getting to that point was a little more difficult in terms of debugging because the watch window doesn't seem to present the values as I expected. Can anybody tell me whether there is anything I should do to inspect the values in this loop?

The value of mailItem.Subject for instance is shown in the watch as: Object is not of type Microsoft.Office.Interop.Outlook._MailItem (I am a bit confused about the underscore as I read it is simply a naming convention and I believe I have removed the underscores throughout the project for my own preference) But I note that mailItem in the watch is showing as System.__ComObject - is this a clue that is lost on me?

//LOOPING THROUGH MAIL ITEMS IN THAT FOLDER.
foreach (Microsoft.Office.Interop.Outlook.MailItem mailItem in fldMailItems.Items)
{
    if (mailItem.Body != "")
    {
        MyMail mail = new MyMail();
    mail.Subject = (mailItem.Subject == null) ? string.Empty : mailItem.Subject;
    //mail.
    mailItems.Add(mail);
    }
}

To further illustrate the issue as it is applying with Redemption RDOMail, the message box displays as you would expect but the watch window does not show that the property SenderName even exists - it shows base Class as value: object, within which _Identity and Identity both null, and a further Non-Public members with m_ObjjectToDataMap which also has a value of null.
Here is an example then causing the same headache:

    void ConnectOutlook()
    {
         session = new Redemption.RDOSession();
            session.Logon();
            inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);          
    }

    void DisconnectOutlook()
    {
        session.Logoff();
        session = null;
    }


    void MainFormLoad(object sender, EventArgs e)
    {
        try
        {

            ConnectOutlook();

            int i=0;
            foreach ( RDOMail mailItem in inbox.Items.Restrict("[MessageClass] = 'IPM.Note'"))
            {
                i++;
                MessageBox.Show(mailItem.SenderName);
            }

            ....
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Andrew Seabrook
  • 397
  • 2
  • 17
  • This same problem occurs using redemption RDOMail is also showing incorrectly in the watch window. If for instance I put mailItem.To as a watch item it shows Object is not of Type Redemption.IRDOMail But this is not correct as this makes clear: MessageBox.Show(mailItem.To); – Andrew Seabrook Jul 29 '13 at 20:18

1 Answers1

0

Does the happen for all items in the folder or just some? You need to make sure you really have a regular message, bot a report item.

This does not apply to Redemption since in Redemption all message items (RDOReportItem, RDOMeetingIrtem, etc.) are derived from RDOMail.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78