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);
}
....