Solved

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

Posted on 2010-09-10
4
710 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Enabling exchange 2013 read receipt 7 23
Help with opening combobox using VB.NET. 3 26
Looking for an APP to manage tasks and time 3 28
Duplicate email in Outlook. 5 26
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

830 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