J
jmlyle
I'm trying to work with an Access database which was developed by others (now
unavailable).
It seems that moving to Outlook 2003 has crunked up the workings. The Access
app should check a couple of email folders to see if they have mail, and then
process them. Now it gives an error:
"-2147221233 - The operation failed. An object could not be found"
These folders are in an "Additional Mailbox," NOT a shared mailbox. One
added via going to Tools --> Accounts --> change --> More Settings -->
Advanced --> Add mailbox. It apparently worked fine with Outlook XP.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Sub HowManyEmailsAvailable(ThisForm As Form)
Dim oOutlook As New Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oRootFolder As Outlook.MAPIFolder
Dim oContainerFolder As Outlook.MAPIFolder
Dim oSubContainerFolder As Outlook.MAPIFolder
Dim oItem As Outlook.MailItem
Dim oIItems As Outlook.Items
Dim varArray2(0 To 0, 0 To 1) As String
Dim icounter1 As Integer
Dim icounter2 As Integer
Dim message As String
MailboxName = ""
RootFolderName = ""
MailboxName = DLookup("[FileOrFolderLocation]", "qry_Get_Email_Mailbox")
RootFolderName = DLookup("[FileOrFolderLocation]", "qry_Get_Email_RootFolder")
' THESE DLOOKUP's RESOLVE TO:
'MailboxName = "Mailbox - Delta, ATG954DeltaU"
'RootFolderName = "Ed Asst"
'Set up folder names to look for mail items in
varArray2(0, 0) = ("Apprv Pre App"): varArray2(0, 1) = ("Appv Reimb")
'Declare the root mailbox to look in
Set oNameSpace = oOutlook.GetNamespace("MAPI")
' THIS NEXT LINE IS WHAT CAUSES THE ERROR 2147221233
Set oRootFolder = oNameSpace.Folders(MailboxName)
'initialize counters
iPA_Available = 0
iRB_Available = 0
' Set oContainerFolder = oRootFolder.Folders("Ed Asst")
Set oContainerFolder = oRootFolder.Folders(RootFolderName)
icounter2 = 0
Set oSubContainerFolder = oContainerFolder.Folders(varArray2(0, icounter2))
Set oIItems = oSubContainerFolder.Items
iPA_Available = oIItems.Count
icounter2 = 1
Set oSubContainerFolder = oContainerFolder.Folders(varArray2(0, icounter2))
Set oIItems = oSubContainerFolder.Items
iRB_Available = oIItems.Count
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I can get the error to stop by changing the offending line to:
Set oRootFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
But this ends up looking in MY Inbox, not the Additional Mailbox inbox,
which is what I need. I can't find anything that makes sense to me about how
to access an Additional Mailbox.
Any help would be greatly appreciated.
unavailable).
It seems that moving to Outlook 2003 has crunked up the workings. The Access
app should check a couple of email folders to see if they have mail, and then
process them. Now it gives an error:
"-2147221233 - The operation failed. An object could not be found"
These folders are in an "Additional Mailbox," NOT a shared mailbox. One
added via going to Tools --> Accounts --> change --> More Settings -->
Advanced --> Add mailbox. It apparently worked fine with Outlook XP.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Sub HowManyEmailsAvailable(ThisForm As Form)
Dim oOutlook As New Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oRootFolder As Outlook.MAPIFolder
Dim oContainerFolder As Outlook.MAPIFolder
Dim oSubContainerFolder As Outlook.MAPIFolder
Dim oItem As Outlook.MailItem
Dim oIItems As Outlook.Items
Dim varArray2(0 To 0, 0 To 1) As String
Dim icounter1 As Integer
Dim icounter2 As Integer
Dim message As String
MailboxName = ""
RootFolderName = ""
MailboxName = DLookup("[FileOrFolderLocation]", "qry_Get_Email_Mailbox")
RootFolderName = DLookup("[FileOrFolderLocation]", "qry_Get_Email_RootFolder")
' THESE DLOOKUP's RESOLVE TO:
'MailboxName = "Mailbox - Delta, ATG954DeltaU"
'RootFolderName = "Ed Asst"
'Set up folder names to look for mail items in
varArray2(0, 0) = ("Apprv Pre App"): varArray2(0, 1) = ("Appv Reimb")
'Declare the root mailbox to look in
Set oNameSpace = oOutlook.GetNamespace("MAPI")
' THIS NEXT LINE IS WHAT CAUSES THE ERROR 2147221233
Set oRootFolder = oNameSpace.Folders(MailboxName)
'initialize counters
iPA_Available = 0
iRB_Available = 0
' Set oContainerFolder = oRootFolder.Folders("Ed Asst")
Set oContainerFolder = oRootFolder.Folders(RootFolderName)
icounter2 = 0
Set oSubContainerFolder = oContainerFolder.Folders(varArray2(0, icounter2))
Set oIItems = oSubContainerFolder.Items
iPA_Available = oIItems.Count
icounter2 = 1
Set oSubContainerFolder = oContainerFolder.Folders(varArray2(0, icounter2))
Set oIItems = oSubContainerFolder.Items
iRB_Available = oIItems.Count
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I can get the error to stop by changing the offending line to:
Set oRootFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
But this ends up looking in MY Inbox, not the Additional Mailbox inbox,
which is what I need. I can't find anything that makes sense to me about how
to access an Additional Mailbox.
Any help would be greatly appreciated.