Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / January 2008

Tip: Looking for answers? Try searching our database.

Newbie wants to connect using CDO instead of MAPI

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
burkejay - 24 Jan 2008 22:17 GMT
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!
Sue Mosher [MVP-Outlook] - 24 Jan 2008 22:44 GMT
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)

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

>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
[quoted text clipped - 18 lines]
>
> Thanks!
burkejay - 25 Jan 2008 16:29 GMT
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!

> Why? CDO 1.21 always raises security prompts.
>
[quoted text clipped - 32 lines]
> >
> > Thanks!
Ken Slovak - [MVP - Outlook] - 25 Jan 2008 16:35 GMT
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.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Sorry that I failed to mention it is in Access VBA.
>
[quoted text clipped - 5 lines]
>
> Thanks so much for your help!
Sue Mosher [MVP-Outlook] - 25 Jan 2008 17:09 GMT
That's hugely relevant. External Outlook automation is going to raise security prompts in versions before Outlook 2007. See http://www.outlookcode.com/article.aspx?ID=52 for your options.

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> Sorry that I failed to mention it is in Access VBA.
>
[quoted text clipped - 18 lines]
>>
>>     Set olns = Application.GetNamespace(MAPI)

>> >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
[quoted text clipped - 18 lines]
>> >
>> > Thanks!
Dmitry Streblechenko - 24 Jan 2008 23:43 GMT
Firstly, you are using the Outlook Object Model, not MAPI (which is only
accessible in C++ or Delphi).
CDO 1.21 is crippled just like OOM. See
http://outlookcode.com/article.aspx?id=52 for the discussion.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

>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
[quoted text clipped - 18 lines]
>
> Thanks!
burkejay - 25 Jan 2008 16:41 GMT
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.

> Firstly, you are using the Outlook Object Model, not MAPI (which is only
> accessible in C++ or Delphi).
[quoted text clipped - 28 lines]
> >
> > Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.