Solved

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

Posted on 2010-09-10
4
699 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
Comment Utility
0
 
LVL 22

Expert Comment

by:Snarf0001
Comment Utility
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
Comment Utility
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
Comment Utility
My only solution I'm afraid. I don't want to accept my own answers
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

12 Experts available now in Live!

Get 1:1 Help Now