From msAccess find correct email account in outlook

Fordraiders
Fordraiders used Ask the Experts™
on
Access 2010 vba
outlook

What Am I trying to do:
Trying to perform a search in the correct    "Inbox"

First. : When i open my outlook  I have several Profiles under my Primary profile

>fordraiders@zzzz.com
  Inbox

>bluebook
  Inbox
>redbook
  Inbox


I tried to access the profile directly but it still only searches in the main "InbOx"    (fordraiders@zzzz.com)



Before I perform a search I need to make sure I'm looking in the correct profile ?
before i execute any code..

I'm trying to loop through each profile but this is not working ?

' LOOK FOR OUTLOOK OPEN
Dim objOL As Outlook.Application
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.Namespace
Dim myInbox As Outlook.MAPIFolder
Dim myitems As Outlook.Items
Dim myitem As Object
Dim objInsp As Outlook.Inspector
Dim oAccount As Outlook.Account

For Each oAccount In myOlApp.Session.Accounts
  If oAccount = "redbook" Then
      ' code here
  end if
next
 


Thanks
fordraiders
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer

Commented:
Add a watch at
myOlApp.Session.Accounts

Open in new window

and check from the watch window what properties and methods are available...maybe it needs a different approach...

Author

Commented:
John,
I did , it will not loop

fordraiders

Author

Commented:
it finds my main fordraiders@zzz.com

but will not find the others.

dp
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Software & Systems Engineer
Commented:
There seems to be a Stores collection that "contains" the Outlook Accounts
Take a look here

Author

Commented:
That was it ...even my admin for outllok kept calling them profiles. I knew their had to be a specific profile name under current session "Stores"...Phew..

That worked.. had to change a set statement but it listed the stores(profiles).

Dim colStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oRoot As Outlook.folder
 
 Set colStores = Outlook.Application.Session.Stores
 
 For Each oStore In colStores
 
 Set oRoot = oStore.GetRootFolder
 
 Debug.Print (oRoot.FolderPath)

 Next

Thanks !
fordraiders
John TsioumprisSoftware & Systems Engineer

Commented:
Glad it worked out like you wanted

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial