Solved

Working with Outlook 2003 and C#

Posted on 2004-08-16
3
589 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 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