Access and Outlook. Stop prompt for Profile name? -
01-29-2011
, 11:35 PM
I have an application I wrote to view Outlook emails. When I wrote it I
always had Outlook open. It works as expected. My problem is if
Outlook is closed. It prompts me for my Profile name after initially
prompting me for it.
I have some standard code.
Dim oldApp As Object
Set olApp = GetOutlookObject()
This calls a function that looks like this
Public Function GetOutlookObject() As Object
On Error Resume Next
Set GetOutlookObject = CreateObject("Outlook.Application")
If Err.Number <> 0 Then
On Error GoTo 0
On Error Resume Next
Set GetOutlookObject = GetObject(, "Outlook.Application")
End If
End Function
Where I get prompted for selecting an Outlook Profile name is usally at
code such as this where I am getting the folders.
Dim olApp as Object
Dom olName As Object
If Not TypeName(olApp) = "Nothing" Then
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olFolders = olNameSpace.Folders 'prompts for profile
I am not sure why the olFolders line prompts me. Is there any method of
automation where can get my Outlook folder and not be prompted to select
my Profile? |