Messages Collection

The Messages collection contains Message objects used to examine properties of the downloaded messages and the messages headers.

To obtain the Messages collection, either call RetrieveMessages or RetrieveHeaders methods of the POP3 object. The IMAP4 object utilizes the Envelopes collection instead of the Messages collection.

Syntax

Messages.property

 

Properties
Count Returns the number of Message objects in the collection.
Item Returns a reference to Message object in the collection.

 

Remarks

Item is the default property of the collection, so Messages.Item(index) and Messages(index) are equivalents.

To iterate through the collection, you can use either For .. Each statement or any common loop statement such as For .. To.

 

Example

The following examples use different syntax to display "Subject:" field of all messages in the POP3 mailbox. It's assumed the Messages collection has been already obtained with RetrieveHeaders method call and stored in objMessages variable.

For .. Each syntax
For Each objMessage In objMessages
  MsgBox objMessage.Subject
  ' In ASP, use Response.Write instead of MsgBox
Next

 

For .. To syntax
For I = 1 To objMessages.Count
  MsgBox objMessages(I).Subject
  ' In ASP, use Response.Write instead of MsgBox
Next

 

See Also

Message Object, POP3 Object

 


Send feedback to AfterLogic
Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.