Solved

How do I access the Inbox of a second Outlook account in VB .NET?

Posted on 2010-09-09
3
465 Views
Last Modified: 2012-05-10
I've got a small application monitoring the Inbox of my primary Outlook account which works a treat. However, I have a second account and I want the same application to check for unread items in that account's inbox.

My current code includes the following for the default account:

                oNS = PharmarOutlook.GetNamespace("MAPI")

                oInbox = _
                oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
                oItems = oInbox.Items
                oItems = oItems.Restrict("[Unread]=true")

Is it just a question of tweaking this to access the second account?


Many thanks for any assistance given.
0
Comment
Question by:milesryoung
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 33644554
Hi, milesryoung.

Use the same code but instead of GetDefaultFolder use the GetSharedDefaultFolder method.
0
 

Author Closing Comment

by:milesryoung
ID: 33646868
Thanks. This involves having to resolve the recipient name as well but did the trick if you know the names of the accounts.

I now have to ask a new question about how to iterate through the accounts.

myRecipient = oNS.CreateRecipient("Person Name")
myRecipient.Resolve()
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33646892
You're welcome.  
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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
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: …

808 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