Skip to Content
CDO & MAPI Programming with Visual Basic:
book

CDO & MAPI Programming with Visual Basic:

by Dave Grundgeiger
October 2000
Intermediate to advanced
384 pages
10h 22m
English
O'Reilly Media, Inc.
Content preview from CDO & MAPI Programming with Visual Basic:

Establishing a Session

The first step in working with MAPI, regardless of which access methodology is used, is to establish a MAPI session. In CDO, this is done with the Session object’s Logon method. The sample application declares a single Session object with global scope in Globals.bas:

Public gCdoSession As MAPI.Session

If you’re relatively new to Visual Basic, recall that this declaration doesn’t actually create a Session object, it merely declares a variable that is capable of referring to such an object. The object itself is created by this code in subroutine tmrOpenCdoSession_Timer, found in frmMain:

' Instantiate a new session object and logon.
Set gCdoSession = New MAPI.Session
gCdoSession.Logon

The Logon method accepts a number of parameters, all of which are optional. Here is the syntax:

CdoSession.Logon([ProfileName][, ProfilePassword][, ShowDialog][, NewSession]
[, ParentWindow][, NoMail][, ProfileInfo])

The parameters are:

ProfileName

A string that specifies the name of the profile to use for the MAPI session. To cause the MAPI subsystem to prompt the user for the profile name, set this parameter to an empty string and set the ShowDialog parameter to True. These are the default settings for these parameters, so omitting them both has the same effect. Alternatively, the user’s profile names and default profile name can be read from the registry, as explained in Chapter 2. The ProfileName parameter is ignored if the ProfileInfo parameter is supplied.

ProfilePassword ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel® 2007 VBA Programmer's Reference

Excel® 2007 VBA Programmer's Reference

John Green, Stephen Bullen, Rob Bovey, Michael Alexander
COM Programming with Microsoft® .NET

COM Programming with Microsoft® .NET

John Paul Mueller, Julian Templeman

Publisher Resources

ISBN: 156592665XSupplemental ContentCatalog PageErrata