Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-10
4
Medium Priority
?
735 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Changing a few Outlook Options can help keep you organized!
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
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…

971 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