[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

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

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
milesryoung
Asked:
milesryoung
  • 2
1 Solution
 
David LeeCommented:
Hi, milesryoung.

Use the same code but instead of GetDefaultFolder use the GetSharedDefaultFolder method.
0
 
milesryoungAuthor Commented:
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
 
David LeeCommented:
You're welcome.  
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now