[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Retrieving emails from Outlook using Access 2010 vba and Late Binding

Posted on 2013-05-16
11
Medium Priority
?
843 Views
Last Modified: 2013-05-30
I am using late binding in retrieving emails from Outlook. Therefore, I am not checking the Microsoft Outlook 14.0 Object Library reference within Tools-References.

I am using the following code to retrieve emails from Folder B:
dim objOutlook as Object
dim OutlookNameSpace as Object
dim Inbox as Object

set objOutlook = GetObject (, "Outlook.application")
set OutlookNameSpace = objOutlook.GetNamespace("MAPI")

set Inbox = OutlookNameSpace.GetDefaultFolder(6).Folders("A").Folders("B")

This code works correctly. Now, I need to retrieve emails from a folder, which is not the Default Inbox folder. Prior to using late binding, I was using the following statement to retrieve these emails:

set Inbox = objOutlook.GetNamespace("Mapi").Folders("Mailbox - DDD").Folders("Inbox").Folders("New Entries")

How is the above statement used with late binding?
0
Comment
Question by:newbie46
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 58
ID: 39171481
<<How is the above statement used with late binding? >>

 Should be the same.

Jim.
0
 

Author Comment

by:newbie46
ID: 39171533
Jim,
I get an error when using:

set Inbox = OutlookNameSpace.Folders("Mailbox - DDD").Folders("Inbox").Folders("New Entries")

I am not at work today, so cannot provide the exact message.

Similar to using GetDefaultFolder(6) when accessing the default Inbox folder, is there another statement needed when accessing an Inbox folder which is not the default inbox folder?
0
 

Author Comment

by:newbie46
ID: 39171567
Jim,
From a post that I just found via the internet, it looks as though the statement would be:

set Inbox = OutlookNameSpace.GetDefaultFolder(6).Folders("Mailbox - DDD").Folders("Inbox").Folders("New Entries")

Does this look correct? Since I am not in the office, I cannot test this to verify.

Thanks.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 58
ID: 39171582
That should be it.  Error would be helpful.

Jim.
0
 
LVL 58
ID: 39171592
<<set Inbox = OutlookNameSpace.GetDefaultFolder(6).Folders("Mailbox - DDD").Folders("Inbox").Folders("New Entries")>>

 Where is mailbox -DDD?  Is it within the Inbox folder?

Jim.
0
 

Author Comment

by:newbie46
ID: 39171599
Jim,

The posting at http://www.slipstick.com/outlook-developer/working-vba-nondefault-outlook-folders/ states the following:

To use a folder at the same level as the Default folders (such as Calendar, Inbox etc), use this in place of Set Items = Ns.GetDefaultFolder(olFolderCalendar).Items, where SharedCal is the folder name:

Set Items = Session.GetDefaultFolder(olFolderCalendar).Parent.Folders("SharedCal").Items
 
-----------------------------------------------

Therefore, would Session be needed, as in the following statement?
set Inbox = Session.GetDefaultFolder(6).Folders("Mailbox - DDD").Folders("Inbox").Folders("New Entries")
0
 

Author Comment

by:newbie46
ID: 39171607
Jim,
No, DDD is not within the mailbox folder. Mailbox - DDD is shared inbox.
0
 

Author Comment

by:newbie46
ID: 39171641
Sorry. DDD is not within the Inbox folder. Mailbox - DDD is a shared mailbox that multiple people can access. Within this Mailbox - DDD is an Inbox folder, which is then synonymous in terms of levels to the default Inbox folder on each person's machine.
0
 

Author Comment

by:newbie46
ID: 39188096
Jim,
Any ideas?
0
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 39188452
Sorry I missed you comment.

 I would put a STOP right above this:

set Inbox = OutlookNameSpace.Folders("Mailbox - DDD").Folders("Inbox").Folders("New Entries")

 Execute and then from the debug window, you can feel your way through the objects at that point.  ie.

 ?  OutlookNameSpace.Folders(0).Name  

 would give you the name of the first

OutlookNameSpace.Folders(1).Name

 Would give you the name of the second and so on.  WIthin a few minutes, you should be able to determine the objects you need to reference to get to the mail folder you want.

Jim.
0
 

Author Comment

by:newbie46
ID: 39207319
Jim,
Sorry for the delay. I finally had the chance to try this at the office and was able to find the folder using the above suggestion.

Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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