Solved

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

Posted on 2010-09-09
3
457 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Use email signature images to promote corporate certifications and industry awards.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
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…

708 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

13 Experts available now in Live!

Get 1:1 Help Now