Solved

Working with Outlook 2003 and C#

Posted on 2004-08-16
3
584 Views
Last Modified: 2008-01-09
I'm currently working on a program which checks my Outlook Profile for Mail Delivery Reports. As they are other objects than MailItems (that are ReportItems), I have a problem to list all the items in the inbox. Is there a way to filter the inbox via C# to list only the ReportItems.

For example i've this:
foreach(Outlook.ReportItem oReport in oItems)
{
   Console.WriteLine(oReport.Subject);
}

but as soon as a MailItem occurs I'll get an error.

Well filtering is the first problem ... the other problem I have is, I've created a special Profile (Control Panel -> Mail) where I loaded another PST file with Delivery Report Mails in it. The problem I have is, how can I connect to the PST file via the Profile? Or how do I connect to another folder than the InboxFolder(Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);)
0
Comment
Question by:SiraX
3 Comments
 
LVL 3

Assisted Solution

by:gillgates
gillgates earned 250 total points
Comment Utility
I am not familiar with Outlook.ReportItem but did you see if there was something like Outlook.ReportItem.Type or something like that so if you noticed that an actual report item have value, lets say 1 and a mail item had value 2 you could skip over it?
0
 
LVL 4

Accepted Solution

by:
Jigit earned 250 total points
Comment Utility
Try the following:
foreach(Outlook.ReportItem oReport in oItems)
{
   if ( oReport is MailItem ) continue;
   Console.WriteLine(oReport.Subject);
}

What error are you getting? Maybe the error is Outlook security restriction?
There is a great developempent tool working around the security limitations of Outlook, called Outlook Redemption:
http://www.dimastr.com/redemption/

There is another tool of the same guy called Outlook Spy:
http://www.dimastr.com/outspy/
It displays all the properties/method/events/etc of any Outlook object and enables running scripts from Outlook itself. Very helpful for Outlook integration development.

HTH,
Jigit
0
 

Author Comment

by:SiraX
Comment Utility
Jigit the loop won't work as oItems also can contain MailItems, at that moment you can't assign the Item to oReport as ReportItem.

In fact I resolved my problem ... I just do a for loop and work with GetNext in a try catch.

the other problem with the folder selection is also solved

I will split the points to you two as were the only ones who tried to help me out ...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now