Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

Chili!POP3 (POP3) Component

The Chili!POP3 component retrieves e-mail messages from a POP3 server from an ASP script. This component has two main interfaces. The POP3 interface creates and controls the connection to a POP3 server. The Message interface exposes all of the properties of a single message. Additional interfaces are exposed to support retrieval of message lists and message attachments.

Chili!POP3 Registry Settings

The Chili!POP3 component does not use registry settings.

Chili!POP3 Syntax

The Chili!POP3 component is registered with the ProgId of "CHILI.POP3.1."

The following ASP script written in VBScript creates an instance of the component:

Set pop3 = Server.CreateObject( "CHILI.POP3.1" )

Chili!POP3 POP3 Interface

The POP3 interface creates and controls a connection to a POP3 server.

POP3 Interface Properties

The POP3 interface exposes no properties.

POP3 Interface Collections

·   Messages

POP3 Interface Messages Collection

The Messages collection is a collection of Message objects, as described later in "Chili!POP3 Message Interface." This collection is read-only and does not support the standard Append or Delete collection methods.

POP3 Interface Methods

The following methods control a network connection to a POP3 server.

·   Connect  

·   Delete   

·   Disconnect   

·   Reset

POP3 Interface Connect Method

The Connect method establishes a network connection to a POP3 server.

Arguments:

Host

The hostname of the server with which to connect.

UserId

The User ID required for connecting with the server.

Password

The password required for connecting with the server.

Example:

See the following Disconnect example.

POP3 Interface Disconnect Method

The Disconnect method disconnects from the POP3 server.

Example:

Set pop3 = Server.CreateObject("CHILI.POP3.1")

pop3.Connect "mail.foo.com", "myuserid", "mypsswd"

pop3.Disconnect

POP3 Interface Delete Method

The Delete method deletes a message on the POP3 server. This does not delete the message from the Messages collection.

Arguments:

Id

0-based index for the message in the message collection.

Reset:

Returns the POP3 server to the beginning of the transaction state (Connected) and ignores any commands and their effect on the connection. For example, any messages that were deleted from the mailbox are restored to their un-deleted state.

Example:

Set pop3 = Server.CreateObject("CHILI.POP3.1")

pop3.Connect "mail.foo.com", "myuserid", "mypsswd"

pop3.Reset

pop3.Disconnect

Chili!POP3 Message Interface

The Chili!POP3 component Message interface provides access to the messages currently in the mail store on the connected server. The properties, methods, and collections of the Message object are used to access those messages.

There are varying network costs associated with accessing the different properties of a message. For POP3 servers that support the optional TOP command, accessing any header information and the first few lines of the message can be accomplished without paying the data transfer overhead of moving the entire message from the server to the client.

Note

When requesting any of the properties that can be gathered without retrieving the entire message, the component first attempts the TOP command. If that command fails, the component then attempts to fulfill the property request via the full message RETR command.

Message Interface Properties

(LW means it can be "lightweight" on POP3 servers supporting the TOP command.)

·   From(LW)  

·   Subject(LW)  

·   Size(LW)

·   DateSent(LW)  

·   DateReceived(LW)

·   MsgId(LW)

·   MsgUID(LW)  

·   HasAttachments(LW) 

·   Message 

Message Interface From Property (Read Only)

The From property is a string that indicates who sent the e-mail message.

Message Interface Subject Property (Read Only)

The Subject property is a string that indicates the subject of the message. It may be Null (empty string).

Message Interface Size Property (Read Only)

The Size property indicates the total size of the current message in bytes.

Message Interface DateSent Property (Read Only)

The DateSent property indicates the date and time that the message was sent.

Message Interface DateReceived Property (Read Only)

The DateReceived property indicates the date and time that the message was received.

Message Interface MsgId Property (Read Only)

The MsgId property indicates the message ID of the current message in the collection.

Message Interface MsgUID Property (Read Only)

The MsgUID property indicates whether the server supports the UIDL command. It returns 0 if the server does not support this command.

Message Interface HasAttachments Property (Read Only)

The HasAttachments property provides an "educated guess" based on the message headers (to be lightweight) as to whether the message has attachments.

Message Interface Message Property (Read Only)

The Message property is a string that specifies the content of the message.

Message Interface Collections

The Message interface collections are as follows:

·   To(LW)   

·   CC(LW)

·   Headers(LW)  

·   Attachments  

Message Interface To Collection

The To collection is the list of e-mail addresses to which the message was sent. The collection is read-only and does not support the standard Append or Delete methods.

Message Interface CC Collection

The CC collection is the list of e-mail addresses to which the message was sent as a carbon copy. The collection is read-only and does not support the standard Append or Delete methods.

Message Interface Attachments Collection

The Attachments collection is the list of attachments to the current e-mail message, consisting of file name(s) and description(s). The collection is read-only and does not support the standard Append or Delete methods.

Message Interface Headers Collection

The Interface Headers collection is a collection of all message headers for the current e-mail message. This includes headers that are also accessible via friendly named fields or other collections, such as To, From, and DateSent. This collection can be accessed via the header name or index. This collection is read-only and does not support the standard Append or Delete methods.

Message Interface Methods

·   PreviewMessage 

·   SaveAttachments 

Message Interface PreviewMessage Method

The PreviewMessage method returns the specified number of lines of the message body. For servers that support the TOP command, this is performed without retrieving the entire message body. For messages with attachments or messages that consist entirely of binary data (which may be ascertained via the Headers collection) the first N lines of the message might not be meaningful to a human reader.

Message Interface PreviewMessage Arguments

Lines

The number of lines to return.

Message Interface SaveAttachments Method

The SaveAttachments method saves e-mail attachments to a specified directory on the server.

Message Interface SaveAttachments Arguments

Directory path on the Server

The complete path name to the directory on the server where attachments are to be saved.

Note

In a shared Web hosting environment, such as an ISP, you might not know the directory structure above the document root for your virtual host. In this situation, you cannot specify an absolute path name for the file, so you must use the Server.mapPath directive instead.

Note about To, CC, and Headers

To, CC, BCC, and Headers are BSTR collections using the Count method to obtain the total number of items in the collection and the Item method to obtain each item. The difference is that for To, CC, and BCC, the first argument of Item is a 0-based index, while for Headers, the first argument is a string that indicates the name of the header item (for example, From, To, Subject, and so forth).

Message Interface SaveAttachments Example

Set pop3 = Server.CreateObject("CHILI.POP3.1")

pop3.Connect "mail.foo.com", "myuserid", "mypsswd"

For each item in pop3.Messages

 For each CC in Item.CC

  MsgBox CC

 next

next

pop3.Reset

pop3.Disconnect

Chili!POP3 Attachment Interface

The Chili!POP3 Attachments collection of the Message object provides access to the attachments currently in an e-mail. The properties and methods of the Attachment object are used to access those attachments.

Attachment Interface Properties

·   FileName   

·   ContentType  

·   FileSize 

·   Base64

Attachment Interface FileName Property (Read Only)

The FileName property is a string that indicates the name of the attachment.

Attachment Interface ContentType Property (Read Only)

The ContentType property is a string that indicates the content type of the attachment.

Attachment Interface FileSize Property (Read Only)

The FileSize property is a number that indicates the size of the attachment in bytes.

Attachment Interface Base64 Property (Read Only)

The Base64 property is a Boolean value that indicates whether the attachment is Base64 encoded.

Attachment Interface Methods

·   SaveToFile  

·   Read

Attachment Interface SaveToFile Method

The SaveToFile method saves the attachment on the server.

Attachment Interface SaveToFile Arguments

Directory

The full directory path on the server.

Note

In a shared Web hosting environment, such as with an Internet Service Provider, you might not know the directory structure above the document root for your virtual host. In this situation, you cannot specify an absolute path name for the file, so you must use the Server.mapPath directive instead.

Attachment Interface Read Method

The Read method reads the attachment.

Attachment Interface Read Arguments

Nsize

The number of bytes to read from the attachment. This argument is optional. If missing, the entire attachment is read.

Pbytes

A safe array of bytes.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.