Envelope Object
You can use the Envelope object to examine properties of messages located on the IMAP4 server.
Syntax
Envelope.property
Properties | |
AddressDelimiter | Specifies the delimiter to be used to separate individual items when returning e-mail addresses' or friendly names' strings. |
BCCAddr | The e-mail addresses of the blind-carbon-copy recipients. |
BodyStructure | A reference to the root BodyPartStructure object of the message structure tree. Can be Nothing. |
CCAddr | The e-mail addresses of the carbon-copy recipients. |
CCFriendlyName | The friendly names of the carbon-copy recipients. |
Date | The date and time of the moment when the server received the message. |
Flags | The flags set for the message. |
FlagsAsString | All the flags (including non-standard ones) which are set for the message, as a string. |
FromAddr | The e-mail address of the sender. |
FromFriendlyName | The friendly name of the sender. |
MessageID | The value of "Message-ID:" header of the message. |
MessagePreview | A reference to the Message object which contains the partial message. Can be Nothing. |
PureCCAddr | The e-mail addresses (with friendly names removed) of the carbon-copy recipients. |
PureFromAddr | The e-mail address (with friendly name removed) of the sender. |
PureToAddr | The e-mail addresses (with friendly names removed) of the primary recipients. |
ReplyToAddr | The e-mail address of the entity specified to receive all replies to the message. |
RFC822Date | The date and time as it's specified in "Date:" header of the message. |
Size | The size of the entire message (in bytes). |
Subject | The subject of the message. |
ToAddr | The e-mail addresses of the primary recipients. |
ToFriendlyName | The friendly names of the primary recipients. |
UID | The Unique-ID (UID) of the message on the IMAP4 server. |
Remarks
The Envelope
object allows you to preview messages and examine their properties without overhead
of downloading entire messages.
The Envelope object effectively replaces message headers widely used
in the POP3-based e-mail solutions. With the IMAP4 envelopes, you have access
to the extra information not available with the POP3 protocol such as the date
and time of the moment when the server received the message (Date property).
If you need to examine certain message headers which are not exposed by the
Envelope object (such as "X-Spam:"), you can still obtain the
message headers via MessagePreview property. Also, this property can
be used to preview some part of the message body.
Also, the Envelope object can expose the structure of the message parts
via BodyStructure property. For instance, you can obtain the attachments
filenames, or determine whether the message is HTML-formatted or just plain-text.
To obtain the Envelope object, either call RetrieveEnvelopes
or RetrieveEnvelopesEx
method of the IMAP4 object. These methods
return the Envelopes collection
of the Envelope objects.
Note: By default, BodyStructure and MessagePreview properties
of the Envelope object are available because of additional information
(and network traffic) required to set them. You must use RetrieveEnvelopesEx
method if you want to have these properties set.
Example
The following example connects to the IMAP4 server, logs in certain e-mail account, selects Inbox folder, and displays the size for the first 5 messages.Dim objIMAP4, objEnvelopes, objEnvelope ' Using Visual Basic to create object Set objIMAP4 = CreateObject("MailBee.IMAP4") ' Using ASP to create object ' Set objIMAP4 = Server.CreateObject("MailBee.IMAP4") ' Unlock IMAP4 object objIMAP4.LicenseKey = "put your license key here" ' Set IMAP4 server name objIMAP4.ServerName = "mail.server.com" ' Set user credentials objIMAP4.UserName = "jdoe" objIMAP4.Password = "secret" ' Connect to the server and ' log in email account If objIMAP4.Connect Then ' Select Inbox folder If objIMAP4.SelectMailbox("Inbox") Then ' Get envelopes for the first 5 messages Set objEnvelopes = _ objIMAP4.RetrieveEnvelopes(1, 5, False) ' Check for errors If Not objIMAP4.IsError Then For Each objEnvelope In objEnvelopes ' Display the message size MsgBox "Size = " & objEnvelope.Size ' In ASP, use Response.Write instead of MsgBox Next End If End If ' Close the connection objIMAP4.Disconnect End If
See Also
BodyPartStructure Object, Envelopes Collection, IMAP4 Object, Message Object