Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-09-10
4
Medium Priority
?
719 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
[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
  • 2
4 Comments
 
LVL 7

Expert Comment

by:EYoung
ID: 33647413
0
 
LVL 23

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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

715 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