J
Justin
Hello all. I have a question about automation and public
email boxes. I have created a database that will import
items from an email box into a table. It allows the user
to pick from a folder in their outlook. It stores the
folder's entryid and storeid in a table to use when
importing. But, I've encountered a strange problem when
the user selects a public folder and then tries to run
any of the routines. If the user had started Outlook
themselves it will recognize the folder just fine. If
Outlook was started programatically, it does not find the
folder. Below is the code I use to initialize the otlApp
variable:
Private Sub otlIni()
On Error GoTo constErr
Set otlApp = GetObject(, "Outlook.Application")
constErr:
Select Case Err.Number
Case 0
Case 429 ' Outlook not open
Set otlApp = CreateObject
("Outlook.Application")
Case Else
MsgBox "Error: " & Err.Number & ". " &
Err.Description
End Select
End Sub
Here is the function I use to get the folder that the
user selected:
Function otlGetFolderFromID(strEntryID As String,
strStoreID As String) As Outlook.MAPIFolder
On Error Resume Next
If otlApp Is Nothing Then
otlIni
End If
Set otlGetFolderFromID =
otlApp.Session.GetFolderFromID(strEntryID)
End Function
I have a simple test routine that basically just displays
all of the emails in the folder. But, if it is a public
folder and the otlApp was initialized using the
CreateObject function, then the otlGetFolderFromID
function fails. Is there some other step that I am
missing to initialize the session so that it recognizes
the public folders id's? Thanks in advance for your help!
email boxes. I have created a database that will import
items from an email box into a table. It allows the user
to pick from a folder in their outlook. It stores the
folder's entryid and storeid in a table to use when
importing. But, I've encountered a strange problem when
the user selects a public folder and then tries to run
any of the routines. If the user had started Outlook
themselves it will recognize the folder just fine. If
Outlook was started programatically, it does not find the
folder. Below is the code I use to initialize the otlApp
variable:
Private Sub otlIni()
On Error GoTo constErr
Set otlApp = GetObject(, "Outlook.Application")
constErr:
Select Case Err.Number
Case 0
Case 429 ' Outlook not open
Set otlApp = CreateObject
("Outlook.Application")
Case Else
MsgBox "Error: " & Err.Number & ". " &
Err.Description
End Select
End Sub
Here is the function I use to get the folder that the
user selected:
Function otlGetFolderFromID(strEntryID As String,
strStoreID As String) As Outlook.MAPIFolder
On Error Resume Next
If otlApp Is Nothing Then
otlIni
End If
Set otlGetFolderFromID =
otlApp.Session.GetFolderFromID(strEntryID)
End Function
I have a simple test routine that basically just displays
all of the emails in the folder. But, if it is a public
folder and the otlApp was initialized using the
CreateObject function, then the otlGetFolderFromID
function fails. Is there some other step that I am
missing to initialize the session so that it recognizes
the public folders id's? Thanks in advance for your help!