Solved

Working with Outlook 2003 and C#

Posted on 2004-08-16
3
586 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
ID: 11812178
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
ID: 11824709
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
ID: 11825633
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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