Class Accounts (Outlook VBA)

The Accounts collection object contains a set of Account objects representing the accounts available for the current profile. To use a Accounts class variable it first needs to be instantiated, for example


Dim accs as Accounts
Set accs = Session.Accounts

For Each

Here is an example of processing the Accounts items in a collection.


Dim acc As Account
For Each acc In Session.Accounts
	
Next acc

Class

Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for OlObjectClass.


Dim oocsClass As OlObjectClass
oocsClass = Session.Accounts.Class

Count

Returns a Long indicating the count of objects in the specified collection.


Dim lngCount As Long
lngCount = Session.Accounts.Count

Item

Returns an Account object specified by Index.

Item (Index)

Index: A one-based Long that indexes into the Accounts collection, or a String that specifies the DisplayName of an Account.


Dim acc As Account
Set acc = Session.Accounts(Index:=1)

Session

Returns the NameSpace object for the current session.

Returns Null (Nothing in Visual Basic) if there is no logged-on session. The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements perform the same function: