No longer able to call specific Outlook Profile - prompt interfere

J

JDMAWoods

I've been having trouble for about the past 4 months with the following code
which "should" (because it use to work) open up the specified Outlook profile
programattically. However, something has changed that I cannot pinpoint
which prevents the code from proceeding past the line...

objOutlook = CreateObject("Outlook.Application")

At this point, the profile dialog box opens and waits for user interaction
to proceed. It did not use to occur that way. Is there some registry key I
need to change, or what setting am I missing?

Option Compare Database
Option Explicit

' Variable that holds the name of the mailbox to use
Const MailboxName = "Mailbox - ME"
Const otlProfileName = "MYMail"


Function otlEMailGeneralUse()
On Error GoTo otlEMailGeneralUse_Err

Dim db As Database
Dim rst As Recordset
Dim objNamespace As NameSpace
Dim MAILFolder As MAPIFolder
Dim DIFolder As MAPIFolder
Dim itms As Object
Dim itm As Object
Dim Sign As Property
Dim objOutlook As Outlook.Application

Dim RecCount As Integer

' Open Access query containing data to export to Outlook
Set db = DBEngine.Workspaces(0).Databases(0)
Set rst = db.OpenRecordset("qrySEND-EMAIL")
RecCount = rst.RecordCount

If RecCount = 0 Then
Exit Function
End If

' Open the Outlook Inbox and create a message for each
' Person in the Access query to receive the email
' Check settings in Global Entries at top of Module for details.

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

objNamespace.Logon otlProfileName, "", True, True

Set MAILFolder = objNamespace.Folders(MailboxName).Folders("Inbox")
Set DIFolder = objNamespace.Folders(MailboxName).Folders("Deleted Items")
Set itms = MAILFolder.Items
 
B

BeWyched

Hi

I have had problems in the past with 'CreateObject', specifically when
automating Outlook, which were solved by adding the (supposedly) optional
second parameter to the command which specifies which server to create the
object on. I don't know if this will solve your problem but worth a try:

Try:

objOutlook = CreateObject("Outlook.Application", "LocalHost")

Cheers.

BW
 
J

JDMAWoods

Thanks for the suggestion, but that didn't solve the problem. I added the
extra piece of information, saved the code, restarted the app, and still get
the "Profile Prompt" dialog box from Outlook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top