Newbie wants to connect using CDO instead of MAPI

  • Thread starter Thread starter burkejay
  • Start date Start date
B

burkejay

I have the following VBA code that uses MAPI to get a user's Appointments.
It generates the dreaded security access dialog, so i want to use CDO
instead, but I don't know how.

Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim recip As Outlook.Recipient
Dim rs As Recordset

Set olns = ol.GetNamespace("MAPI")

Set rs = CurrentDb.OpenRecordset("SELECT OUTLOOK_USERID FROM
USER_ACCOUNTS")
rs.OpenRecordset

Set recip = olns.CreateRecipient(rs!OUTLOOK_USERID)
recip.Resolve rem security prompt opens here.

How do I replace the CreateRecipient and resolve with CDO
objects instead?

Thanks!
 
Why? CDO 1.21 always raises security prompts.

Is this code for Outlook VBA? If so, this is your problem:

Dim ol As New Outlook.Application

Instead, use the intrinsic Application object that Outlook VBA exposes:

Set ol = Application

or just

Set olns = Application.GetNamespace(MAPI)
 
Sorry that I failed to mention it is in Access VBA.

I commented out the whole line "Dim ol As New Outlook.Application"
and just did a straight "Set olns = Outlook.Application.GetNamespace("MAPI")"

and I still got the security warning.

Thanks so much for your help!
 
From outside the Outlook VBA, like in Access VBA, you would use New
Outlook.Application.

However, you aren't understanding that the project reference to MAPI is
actually CDO 1.21 and your MAPI.Session is a CDO Session object. CDO is
restricted and no matter what you do if you use it you will get the security
prompts.

I think you are confusing Extended MAPI with CDO (MAPI). Extended MAPI has a
huge learning curve and cannot be programmed using VBA, only C++ or Delphi
in unmanaged code.
 
My mistake, I had skimmed that very discussion and that was where I got
the idea that I needed to use CDO. I must have misread it, sorry.
 
Back
Top