Avatar of Fordraiders
FordraidersFlag for United States of America

asked on 

From msAccess find correct email account in outlook

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
OutlookVBAMicrosoft Access

Avatar of undefined
Last Comment
John Tsioumpris
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

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...
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

John,
I did , it will not loop

fordraiders
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

it finds my main fordraiders@zzz.com

but will not find the others.

dp
ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

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
Glad it worked out like you wanted
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo