If you feel some confusion about any thing or if you do not find what you are looking for, please inform us so that we can improve our documentation accordingly. docs@aspfusion.net

AdvIMAP4

The component allows you to perform retrieve and delete mail messages from any standard IMAP4 server, which compiles with RFC 2060, via a web page and offer much advanced functionality that IMAP4 server support. Access to the component can also be turned on at website basis like all other ASPFusion components. AdvIMAP4 is much more advanced component for mail access protocol IMAP4. The component exposes message headers via properties and handles quoted-printable and base64 decoding file attachments and embedded images also. It provides following operations.

  1. The complete server side mailbox management, such as Create, Delete, Rename, Subscribe, Unsubscribe, Check, Close, Examine, Select, List, Lsub and Status.

  2. Retrieve mail messages from any mailbox using message sequence numbers and UIDs and also can sort the messages in ascending and descending given criteria.

  3. It provides an advanced search mechanism, which can search any mailbox for messages on given criteria.

  4. Mail messages can be copied from one mailbox to any other mailbox using their sequence numbers or UIDs.

  5. Messages status can be changed manually.

  6. It also provides Download and DownloadAs for handling mail attachments. Download operation allows downloading file to client browser with actual file name and DownloadAs operation allows downloading file to client browser with specified name.

<%set Obj = Server.CreateObject("AdvIMAP4.IMAP4")%> 

AdvIMAP4 Properties 

Property

Description

Attachment

Required for Append(optional) and RFC822(optional). It is pipe sign '|' separated list of attachments sent with mail message.
Example:
<%Obj.Attachment = “C:\test1.txt | C:\test2.txt"%>

AttachmentPath

The physical path where attachments will be saved
Example:
<%Obj.AttachmentPath = “C:\Temp”%>

AttachmentPathError

Returns 1 if any error occur in AttachmentPath otherwise 0
Example:
<%if Obj.AttachmentPathError = 1 then
        Error in Attachment Path and attachments could not be
saved
end if %>

AttachmentPathErrorReason

Reports any error that occur due to AttchmentPath
Example:
<%if Obj.AttachmentPathError = 1 then
        Response.Write Obj. AttachmentPathErrorReason
end if %>

AttachmentPathHTTP

URL for the AttachmentPath where attachments are saved
Example:
<%Obj.AttachmentPathHTTP = “http://localhost/temp”%>

Body

Required for Append(optional) and RFC822(optional). It is body of mail message.
Example:
<%Obj.Body = “This is testing message"%>

CC

Required for Append(optional) and RFC822(optional). It is cc address of mail message. It can be single address or semicolon ';' separated list of addresses.
Example:
<%Obj.CC = “cc@company"%>

DataItems

Required for Status, Fetch, Search(optional), Store, UidFetch, UidSearch(optional), UidStore

Valid values are

Status: data items to be retrieved from specified mailbox e.g. messages, recent, uidnext, uidvalidity, and unseen. One can also give combination of all these, separated with space 
 

Fetch and UIDFetch: it is fetch criteria. Valid values for fetch criteria are getheader and getall
 

Search and UIDSearch: e.g. “subject hello”. This will return sequence number of those messages, which contains word hello in their subjects. If not specified then all messages are selected as a result
 

Store and UIDStore: data items to be updated. Valid values are flags, flags.silent, +flags, +flags.silent, -flags, and -flags.silent. Simple flags and flags.silent remove all previous values of flags and set new values of flags for the mail. If + sign is used then previous values of flags are not removed and also new values are placed. - sign is used for performing not of + operation
Example:
<%Obj.DataItems = “GetHeader”%>
 

DataItemValues

Required for Store, UidStore. Updated values for dataitems e.g. \seen, \deleted, \flagged.
One can also give combination of all these separated with space  
Example:
<%Obj.DataItemValues = “\Seen \Deleted”%>

DeleteFile If this property is TRUE then file is deleted from server after downloading. Valid values are
FALSE (default)
TRUE
Example:

<%Obj.DeleteFile
= true%>  
DownloadForceFully If this property is TRUE then file is downloaded forcefully. Valid values are
FALSE (default)
TRUE
Example:

<%Obj.DownloadForceFully
= true%>  

ErrorReason

Reports any errors that occur during the request
Example:
<%if Obj.IsError = 1 then
        Response.Write Obj.ErrorReason
else
        No Error
end if %>

FlagsLists

Required for Append(optional). Flags that are to be set for message e.g. \seen, \draft, \answered, \flagged and \deleted. One can also give combination of all these separated with space. If not specified then no flag is set  
Example:
<%Obj.FlagsLists = “\Seen \Deleted”%>  

From

Required for Append(optional) and RFC822(optional). It is from address of mail message
Example:
<%Obj.From = “from@company"%> 

IsError

Returns 1 if any error occur during the request otherwise 0
Example:
<%if Obj.IsError = 1 then
        Error

else
        No Error
end if
%>

MailBoxName

Required for Append, Create, Delete, Examine, Rename, Select, Status, Subscribe, UnSubscribe, Check, Close, Copy, Fetch(optional, default is Inbox), Search, Store, UidCopy, UidFetch(optional, default is Inbox), UidSearch, UidStore for performing the corresponding action

Example:
<%Obj.MailBoxName = “Inbox”%>  

MessageLiteral

Required for Append. Message that is to be append in specified mailbox  
Example:
<%Message = "From: Micheal\r\n"
Message = Message & "To: David\r\n"

Message = Message & "Subject: Testing"

Obj.MessageLiteral = Message%>

MessageNumberOrUID

Required for Copy, Fetch(optional, default is all message numbers), Store, UidCopy, UidFetch(optional, default is all message UIDs), UidStore. Message sequence numbers or UIDs of messages, for performing action. We can also write it as 3:8 means messages with sequence number starts from 3 and ends at 8. Also 3,8 (comma separated list) can be given which means messages with sequence number 3 and 8 only  
Example:
<%Obj.MessageNumberOrUID = “2,5,8,12,17”%>

MessageType

Required for Append(optional) and RFC822(optional). It is type of mail message. Valid values are

HTML (default)

TEXT
Example:
<%Obj.MessageType = “TEXT"%>

NewMailBoxName

Required for Rename and Copy
Example:
<%Obj.NewMailBoxName = "Inbox1"%>

OrderBy

Required for Fetch(optional), UidFetch(optional). Required for sorting of mails. If not specified then no sorting is performed and mail messages are returned in order as returned by IMAP4 server. Valid sorting criteria are
Subject_ASC
Subject_DESC
From_ASC
From_DESC
To_ASC
To_DESC
Date_ASC
Date_DESC
Size_ASC
Size_DESC
Attachment_ASC(without attachment mails first) Attachment_DESC(with attachment mails first)
Example:
<%Obj.OrderBy = “Size_DESC”%>

Password

Required for connection to server in all methods except if method is Capability
Example:
<%Obj.Password = "Testing"%>

Port

Optional. If not specified then default port 143 is used  

Example:
<%Obj.Port = 842%>

ReferenceName

Required for List(optional), Lsub(optional). Name of a mailbox or level of mailbox hierarchy. If not specified then empty reference name is selected  
Example:
<%Obj.ReferenceName = “Inbox”%>

ServerName

Required. Host name or IP address of the IMAP4 server  
Example:
<%Obj.ServerName = “LocalHost”%>

SortFirst Required for Fetch(optional), required for sorting mail messages first and then return required mail messages. This parameter is only valid if parameter DataItems contains GetHeader and ignored in case of GetAll. If parameter MessageNumberOrUID contains 1:5 and this parameter is set as TRUE then the component will fetch all messages first and will sort on given sorting criteria and then will return mail messages that come in sequence from 1 to 5, and if this parameter is set as FALSE then the component will fetch messages from 1 to 5 and will sort on given sorting criteria and then will return mail messages. Valid values are
TRUE
FALSE (default)
Example:
<%Obj.SortFirst = true%>

Subject

Required for Append(optional) and RFC822(optional). It is subject of mail message
Example:
<%Obj.Subject = “testing"%> 

To

Required for Append(optional) and RFC822(optional). It is to address of mail message. It can be single address or semicolon ';' list of addresses
Example:
<%Obj.To = “to@company"%> 

Type This property is used to set content type for the file to be downloaded. Default value is application/octet-stream.
Example:

<%Obj.Type
= ”application/zip”%>  

UserName

Required for connection to server in all methods except if method is Capability  
Example:
<%Obj.UserName = “David”%>

WildCard

Required for List(optional), Lsub(optional). Mailbox name with possible wildcards. If not specified then empty name is selected. The character "*" is a wildcard, and matches zero or more characters at this position. The character "%" is similar to "*" but it does not match a hierarchy delimiter  

Example:
<%Obj.WildCard = “*”%>

AdvIMAP4 Methods

Method

Parameter

Return Value

Description

Append

None

None

Appends a message to the specified mailbox
Example:
<%Obj.Append()%>

Capability

None

Object

Requests a listing of capabilities that the server supports
Example:
<%set Result = Obj.Capability()
      =Result.Capability
set Result = nothing%>

Check

None

None

Requests a checkpoint of the mailbox, which is specified
Example:
<%Obj.Check()%>

Close

None

None

Closes the mailbox and remove all messages that are flagged for deletion
Example:
<%Obj.Close()%>

Copy

None

None

Copies the specified message(s) from one mailbox to the end of the destination mailbox
Example:
<%Obj.Copy()%>

Create

None

None

Create a mailbox at server with the name specified
Example:
<%Obj.Create()%>

Delete

None

None

Delete a mailbox from server with the name specified
Example:
<%Obj.Delete()%>

DeleteMessages

None

Object

Delete specified message(s) from the mailbox using their sequence numbers
Example:
<%set Result = Obj.DeleteMessages()
       =Result.MessageNumber
set Result = nothing%>

Which is tab separated list of deleted message numbers

Download

Source

None

Download the source file to client’s browser
Example:
<%Obj.Download(Source)%>

DownloadAs

Source
FileName

None

Download the source file with given name to client’s browser
Example:
<%Obj.DownloadAs Source, FileName%>

Examine

None

Object

Select a mailbox at server for read-only access
Example:
<%set Result = Obj.Examine()
    =Result.Flags
    =Result.Exists
    =Result.Recent
    =Result.Unseen
    =Result.PermanentFlags
    =Result.UIDValidity
set Result = nothing%>

Expunge

None

Object

Remove all messages that are flagged for deletion
Example:
<%set Result = Obj.Expunge()
    =Result.MessageNumber
set Result = nothing%>

Which is tab separated list of deleted message numbers

Fetch

None

Array of Objects

Retrieves the data associated with messages, according to the specified fetch criteria using message sequence numbers
Example:
<%set Result = Obj.Fetch()
for each Member in Result
      =Member.MessageNo
      =Member.Priority
      =Member.XF
      =Member.Date
     
=Member.MessageID
      =Member.MimeVersion
      =Member.ContentType
      =Member.From
      =Member.To
      =Member.ReplyTo
      =Member.Subject
      =Member.XMailer
      =Member.UID
      =Member.Status
      =Member.Flags
      =Member.InternalDate
      =Member.Size
      =Member.CC
      =Member.Text
      =Member.HTMLText
      =Member.AttachmentSent
      =Member.AttachmentSaved
      =Member.AttachmentFiles
      set list = Member.ExtraHeaders()
      for each val in list
            =val.Name&" = "&val.Value
      next
      set list = nothing
next
set Result = nothing%>

List

None

Array of objects

Requests a list of mailboxes at server
Example:
<%set Result = Obj.List()
for each Member in Result
     =Member.NameAttributes
     =Member.HierarchyDelimiter
     =Member.Name
next
set
Result = nothing%>

Lsub

None

Array of objects

Requests a subset of user defined "active" or "subscribe" mailbox names
Example:
<%set Result = Obj.Lsub()
for each Member in Result
     =Member.NameAttributes
     =Member.HierarchyDelimiter
     =Member.Name
next
set Result = nothing%>

Rename

None

None

Rename a mailbox at server with the new name specified
Example:
<%Obj.Rename()%>

RFC822

None

Object

Return RFC822 format message which can be further used in Append method for appending message
Example:
<%set Result = Obj.RFC822()
    =Result.Message
set Result = nothing%>
Which is RFC822 format message, then it can be used in Append method for appending message

Search

None

Object

Search the mailbox for messages that match the given search criteria and retrieve the corresponding message sequence numbers
Example:
<%set Result = Obj.Search()

  
=Result.MessageNumber
set Result = nothing%>
 
Which is tab separated list of searched message numbers

Select

None

Object

Select a mailbox at server for read and write access
Example:
<%set Result = Obj.Select()
    =Result.Flags
    =Result.Exists
    =Result.Recent
    =Result.Unseen
    =Result.PermanentFlags
    =Result.UIDValidity
set Result = nothing%>

Status

None

Object

Requests the status of a particular mailbox at server
Example:
<%set Result = Obj.Status()

  
=Result.Messages
   =Result.UnSeen
   =Result.UIDNext
   =Result.UIDValidity
   =Result.Recent
set Result = nothing%>

Store

None

Array of objects

Updates message data associated with message sequence numbers in a specified mailbox
Example:
<%set Result = Obj.Store()
for each Member in Result
   =Member.MessageNumber
   =Member.Flags
next
set
Result = nothing%>

Subscribe

None

None

Adds the specified mailbox name to the server's set of "active" or "subscribed" mailbox list
Example:
<%Obj.Subscribe()%>

UIDCopy

None

None

Copies the specified message(s) using their unique identifiers from one mailbox to the end of the destination mailbox
Example:
<%Obj.UIDCopy()%>

UIDDeleteMessages

None

Object

Delete specified message(s) from the mailbox using their UIDs
Example:
<%set Result =
Obj.UIDDeleteMessages()

=Result.MessageNumber
set Result = nothing%>

Which is tab separated list of deleted message numbers

UIDFetch

None

Array of objects

Retrieves the data associated with messages, according to the specified fetch criteria using message UIDs
Example:
<%set Result = Obj.UIDFetch()
for each Member in Result
      =Member.MessageNo
      =Member.Priority
      =Member.XF
      =Member.Date
      =Member.MessageID
      =Member.MimeVersion
      =Member.ContentType
      =Member.From
      =Member.To
      =Member.ReplyTo
      =Member.Subject
      =Member.XMailer
      =Member.UID
      =Member.Status
      =Member.Flags
      =Member.InternalDate
      =Member.Size
      =Member.CC
      =Member.Text
      =Member.HTMLText
      =Member.AttachmentSent
      =Member.AttachmentSaved
      =Member.AttachmentFiles
      set list = Member.ExtraHeaders()
      for each val in list
            =val.Name&" = "&val.Value
      next
      set list = nothing
next
set
Result = nothing%>

UIDSearch

None

Object

Search the mailbox for messages that match the given search criteria and retrieve the corresponding message unique identifiers 
Example:
<%set Result = Obj.UIDSearch()
    =Result.MessageNumber
set Result = nothing%>

Which is tab separated list of searched message numbers

UIDStore

None

Array of objects

Updates message data associated with message unique identifiers in a specified mailbox
Example:
<%set Result = Obj.UIDStore()
for each Member in Result
   =Member.MessageNumber
   =Member.Flags
next
set
Result = nothing%>

UnSubscribe

None

None

Removes a mailbox from server's subscribed mailbox list
Example:
<%Obj.UnSubscribe()%>

Back

Copyright © 2000, Advanced Communications