Solved

How can I iterate through accounts/mailboxes in Outlook using VB .NET?

Posted on 2010-09-10
4
703 Views
Last Modified: 2013-11-25
Hi,

I have a small application which monitors unread mail in a user's Outlook application. Some users  have one single account and some people have several (I don't always know how many).

My problem is how to iterate through the accounts/mailboxes and if I can, will the "NewMail" event be fired for all mailboxes?

I've tried e.g. "For each oAccount in oAccounts" but keep getting a "This is read-only memory" error for some reason. Do I have to loop through Namespace recipients and resolve them all instead?

I'm using Outlook 2003 and Visual Studio 2008

0
Comment
Question by:milesryoung
  • 2
4 Comments
 
LVL 7

Expert Comment

by:EYoung
ID: 33647413
0
 
LVL 22

Expert Comment

by:Snarf0001
ID: 33647498
Please post more code if this still doesn't work for you (not sure where oAccounts is coming from):
but looping through the SESSION accounts is how I've done it:

app = new Outlook.Application()
for each account in app.Session.Accounts
0
 

Accepted Solution

by:
milesryoung earned 0 total points
ID: 33799400
I tried Session.Accounts but I just keep getting errors with "Reading from protected memory" error. I've just looped through folders looking for "Posteingang" and "Postfach" (German for "Inbox" and "Mailbox") as a temporary fix to this.
0
 

Author Closing Comment

by:milesryoung
ID: 38504526
My only solution I'm afraid. I don't want to accept my own answers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

910 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

21 Experts available now in Live!

Get 1:1 Help Now