I made airxmail swc file on google codes.
The file is draft implemetation version for IMAP4.
So if you don’t want to use draft version, please wait…

It doen’t support IMAP4 all functions.
But it is available to get e-mail message from imap server, like gmail imap.

These code are sample to connect and get message from gmail account.

Create client instance
import com.coltware.airxmail.imap.IMAP4Client;

private var client:IMAP4Client;

public function init():void{

	client = new IMAP4Client;
	client.host = "imap.gmail.com";
	client.port = 993;
	client.socketObject = new SecureSocket();
mail flow to connect and get e-mail
//  Set handler for Folder Result

//  Set handler for UID list result ( uid is a key to get e-mail from server )

//  Set message handler 

//  Set username and password, and invoked connect method

//  get subscribed folder list

// logout 
Implemantation of folder result handler
private function folderListResult(event:IMAP4Event):void{
  var folder:IMAP4Folder = event.result as IMAP4Folder;
  trace("NAME=>[" + folder.name + " --> " + folder.nameUTF8 + "]");



If the folder’s noselect property is true, you can NOT select mailbox,



If you want to get ALL messages from the folder,


If you know the folder name ( ex “INBOX” ) and want to get ALL messages form the folder,
you don’t need to get folder list, so you can change main flow source as following below..


// client.lsubBlocking();
Implemantation of message get handler

// result for search method
private function uidList(event:IMAP4ListEvent):void{
for(var i:int = 0; i

Related Posts

19 Responses to “airxmail: IMAP4 draft implementation”

  • Bhushan より:

    It is a very nice library which i was looking for the long time.I am using the IMAP implementation of your library. My inbox contain nearly 1500 mail but i was able to get only 8-10 mail using that after that it gets stuck.The other issue which i face is that the code does not run every time some time the handle message listener is not called. Please let me know what is the issue.

  • coltware より:

    Thank you for your comment.

    Please let me know your environment.
    FlexSDK version, Airxmail version or revision if you checkout from source repository.
    And I want to know about IMAP server.
    ex) gmail , yahoo.com ..

    I want to resolve your problem and my problem too.

    >.The other issue which i face is that the code does not run every time some time the handle message listener is not called.

    That’s my issue too in gmail.
    If you use SecureSocket class in AIR2, please change TLSSocket in cyrpto3 library.
    In my case, That resolved the problem.

    If you can show me the sources, please send my e-mail.


  • Bhushan より:

    Thanks for the prompt reply. Please find the needed information.

    1. Windows XP
    2. Flash builder sdk 4.1.0
    3. IMAP Server – Gmail
    4. coltware_airxmail_air2_r78-dev-imap4.swc

    Changing the socket to TLSSocket doesnt work for me at all.


  • Will より:

    This is a great library. How is the best way of retrieving the status \Seen, \Answered of a message?

  • coltware より:

    I wrote sample code for add flags and remove flags.

    private function uidList(event:IMAP4ListEvent):void{
    for(var i:int = 0; i

  • Will より:

    Thanks very much for the reply. My question is if I use the message() or header() function to retrieve message details is there any way of accessing what the flags are for that message as they are pull them from the server. the add and remove flag functions work beautifully just trying to get the initial headers.


  • coltware より:

    I see….
    At first, I can’t catch the means of ‘retrieving’.
    I forgot to think about it….
    It is strange that it can set flags, but can NOT get flags..

    I’ll try to make it.
    Now I am making IMAP implementation while exploring general usage for imap.
    That kind of comments can help me.


  • Will より:

    Thank you. This library is awesome and am using it for a personal project with a short time frame. Is it a big change to add this functionality? I apologize if I have created more work for you.

  • coltware より:

    >a big change to add this functionality?
    Not so much.

    I made to get flags from header()/message() result at r100(Subversion revision 100).

    private function handleMessage(event:IMessageEvent):void{
    // only IMAP
    var imapEvent:IMAP4MessageEvent = event as IMAP4MessageEvent;
    log.info(“FLAGS :” + imapEvent.flags);
    // \Answered,\Flagged,\Seen

  • Will より:

    Thank you for such a quick fix.

  • Vikram より:


    Its very beautiful library….. I want to show the newest received mails at first.When I fetch the mails it shows from the very oldest mail. Is there any function to show the newest mails at first…

    Thank you

  • coltware より:

    Thank you for using my library.

    > Is there any function to show the newest mails at first…
    No, But I am preparing now.

    So please use ‘search’ command and arguments so far.

    If you want to see recent mails…

    If you want to see unseen and recent mails…
    client.selectMailbox(folder).search( IMAP4Search.and(IMAP4Search.FLAG_RECENT,IMAP4Search.FLAG_UNSEEN));


  • Vikram より:


    ok, thank u very much…

  • Vikram より:


    Is it possible to delete a list of selected mails in server using message-id….

    I know there is a function client.deleteMailBox(); but i dont know how to do?

    Can u give simple code to do it?

  • Pranav より:


    This seems to be a great library.
    I would like to know how I can display all the messages that are there in the inbox in a Flex datagrid or list. Is there some array or something as a property of the client?

    Please give full code (from initialization) because I am unable to piece together a working demo from the documentation available on site.

    For your information, I am using airxmail 0.7 on air 3 with Flash Builder 4 on Windows XP


  • Pranav より:


    I managed to put together the code on your site to pull messages from the server.

    Is there any way to know if the message is new or unread or answered etc?

    the IMAP4MessageEvent.flags is giving an empty array

  • coltware より:

    Hi pranav

    >I would like to know how I can display all the messages that >are there in the inbox in a Flex datagrid or list.

    Sorry, airxmail is not UI library.
    So please store messages to file or DB or memory, then use DataGrid or List.

    > Is there any way to know if the message is new or unread or answered etc?

    Some(etc gmail) imap server doesn’t reply flags on header() or message() method.
    I don’t know why.

    So I am preparing API(function) to make your own IMAP command.

  • Kay より:

    Hello! Glad that there is a library of this kind. Can someone confirm if it has the required APIs to search the address book (via IMAP) and get relevant details.

    The idea is to provide the domain\username, password and Server information and search for names / ids from the address book over IMAP. Say for example, the user types in the first few letters or the last name and you list down the set of users which he can select.

    While I have just downloaded the swc, any insights into that will be very helpful to close down some items in my backlog quickly. Thanks!

  • coltware より:

    Hi kay

    >APIs to search the address book (via IMAP) and get relevant details.
    I think most of people want to have these functions too.
    But I don’t know these API(command) in IMAP protocol.

    And recently, address book does not depend on mail box.
    For example google or facebook etc…

    If you find good idea or good library for it ,
    Please let me know.


Leave a Reply

Spam protection by WP Captcha-Free

Add to Google
« 8月   12月 »