newbie46
asked on
Retrieving emails from Outlook using Access 2010 vba and Late Binding
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("M API")
set Inbox = OutlookNameSpace.GetDefaul tFolder(6) .Folders(" A").Folder s("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("M api").Fold ers("Mailb ox - DDD").Folders("Inbox").Fol ders("New Entries")
How is the above statement used with late binding?
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("M
set Inbox = OutlookNameSpace.GetDefaul
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("M
How is the above statement used with late binding?
ASKER
Jim,
I get an error when using:
set Inbox = OutlookNameSpace.Folders(" Mailbox - DDD").Folders("Inbox").Fol ders("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?
I get an error when using:
set Inbox = OutlookNameSpace.Folders("
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?
ASKER
Jim,
From a post that I just found via the internet, it looks as though the statement would be:
set Inbox = OutlookNameSpace.GetDefaul tFolder(6) .Folders(" Mailbox - DDD").Folders("Inbox").Fol ders("New Entries")
Does this look correct? Since I am not in the office, I cannot test this to verify.
Thanks.
From a post that I just found via the internet, it looks as though the statement would be:
set Inbox = OutlookNameSpace.GetDefaul
Does this look correct? Since I am not in the office, I cannot test this to verify.
Thanks.
That should be it. Error would be helpful.
Jim.
Jim.
<<set Inbox = OutlookNameSpace.GetDefaul tFolder(6) .Folders(" Mailbox - DDD").Folders("Inbox").Fol ders("New Entries")>>
Where is mailbox -DDD? Is it within the Inbox folder?
Jim.
Where is mailbox -DDD? Is it within the Inbox folder?
Jim.
ASKER
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(olFold erCalendar ).Items, where SharedCal is the folder name:
Set Items = Session.GetDefaultFolder(o lFolderCal endar).Par ent.Folder s("SharedC al").Items
-------------------------- ---------- ---------- -
Therefore, would Session be needed, as in the following statement?
set Inbox = Session.GetDefaultFolder(6 ).Folders( "Mailbox - DDD").Folders("Inbox").Fol ders("New Entries")
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(olFold
Set Items = Session.GetDefaultFolder(o
--------------------------
Therefore, would Session be needed, as in the following statement?
set Inbox = Session.GetDefaultFolder(6
ASKER
Jim,
No, DDD is not within the mailbox folder. Mailbox - DDD is shared inbox.
No, DDD is not within the mailbox folder. Mailbox - DDD is shared inbox.
ASKER
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.
ASKER
Jim,
Any ideas?
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
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!
Should be the same.
Jim.