Share via


Session Object

Session Object

The Session object contains session-wide settings and options. It also contains properties that return top-level objects, such as CurrentUser.

At a Glance

Specified in type library:

CDO.DLL

First available in:

CDO Library version 1.0.a

Parent objects:

(none)

Child objects:

AddressLists collection Folder (Inbox or Outbox) InfoStores collection

Default property:

Name

Properties

Name

Available since version

Type

Access

AddressLists

1.1

AddressList object or AddressLists collection object

Read-only

Application

1.0.a

String

Read-only

Class

1.0.a

Long

Read-only

CurrentUser

1.0.a

AddressEntry object

Read-only

Inbox

1.0.a

Folder object

Read-only

InfoStores

1.0.a

InfoStore object or InfoStores collection object

Read-only

MAPIOBJECT

1.0.a

IUnknown object

Read/write (Note: Not available to Visual Basic applications)

Name

1.0.a

String

Read-only

OperatingSystem

1.0.a

String

Read-only

Outbox

1.0.a

Folder object

Read-only

OutOfOffice

1.1

Boolean

Read/write

OutOfOfficeText

1.1

String

Read/write

Parent

1.0.a

Object; set to Nothing

Read-only

Session

1.0.a

Session object (itself)

Read-only

Version

1.0.a

String

Read-only

Methods

Name

Available since version

Parameters

AddressBook

1.0.a

(optional) recipients as Object, (optional) title as String, (optional) oneAddress as Boolean, (optional) forceResolution as Boolean, (optional) recipLists as Long, (optional) toLabel as String, (optional) ccLabel as String, (optional) bccLabel as String, (optional) parentWindow as Long

CompareIDs

1.1

ID1 as String, ID2 as String

CreateConversationIndex

1.1

(optional) ParentIndex as String

DeliverNow

1.1

(none)

GetAddressEntry

1.0.a

entryID as String

GetAddressList

1.2

ObjectType as Long

GetArticle

1.2

ArticleID as Long, FolderID as String, (optional) StoreID as String

GetDefaultFolder

1.2

ObjectType as Long, (optional) mailbox as String

GetFolder

1.0.a

folderID as String, (optional) storeID as String

GetInfoStore

1.0.a

(optional) storeID as String

GetMessage

1.0.a

messageID as String, (optional) storeID as String

GetOption

1.2

OptType as String

Logoff

1.0.a

(none)

Logon

1.0.a

(optional) profileName as String, (optional) profilePassword as String, (optional) showDialog as Boolean, (optional) newSession as Boolean, (optional) parentWindow as Long, (optional) NoMail as Boolean, (optional) ProfileInfo as String

SetLocaleIDs

1.1

LocaleID as Long, CodePageID as Long

SetOption

1.2

OptType as String, OptValue as Variant

Remarks

A Session object is considered a top-level object, meaning it can be created directly from a Microsoft® Visual Basic® program. In the CDO for Exchange Library it has a ProgID of MAPI.Session. This code fragment creates a Session object through early binding:

Dim objSession As MAPI.Session
Set objSession = CreateObject ("MAPI.Session")
objSession.Logon
 

This code fragment creates a Session object through late binding:

Dim objSession As Object
Set objSession = CreateObject ("MAPI.Session")
objSession.Logon
 

Generally, early binding is preferable, because it enforces type checking and generates more efficient code. Note that you specify the full ProgID “MAPI.Session” instead of just “Session” in order to distinguish a MAPI session from other types of sessions available to a Visual Basic program through other object libraries.

In both cases, after you create a new Session object, you use the Logon method to initiate a session with MAPI. No other activities with CDO are permitted prior to a successful logon. The only exception to this rule is the Session object’s SetLocaleIDs method.