We help IT Professionals succeed at work.

From msAccess find correct email account in outlook

Fordraiders
Fordraiders asked
on
172 Views
Last Modified: 2017-03-10
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

John TsioumprisIT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2019

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
IT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

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 TsioumprisIT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Glad it worked out like you wanted

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions