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 client.addEventListener(IMAP4Event.IMAP4_FOLDER_RESULT,folderListResult); // Set handler for UID list result ( uid is a key to get e-mail from server ) client.addEventListener(IMAP4ListEvent.IMAP4_RESULT_UID_LIST,uidList); // Set message handler client.addEventListener(IMAP4MessageEvent.IMAP4_MESSAGE,handleMessage); // Set username and password, and invoked connect method client.setAuth(username,password); client.connect(); client.login(); // get subscribed folder list client.lsubBlocking(); // logout client.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(!folder.noselect){
client.selectMailbox(folder).search(IMAP4Search.dateSentSince("2010/10/01"));
}
}
POINT1
if(!folder.noselect){
}
If the folder’s noselect property is true, you can NOT select mailbox,
POINT2
client.selectMailbox(folder).search(IMAP4Search.dateSentSince("2010/10/01"));
If you want to get ALL messages from the folder,
client.selectMailbox(folder).search(IMAP4Search.ALL);
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.login();
// client.lsubBlocking();
client.selectMailbox("INBOX").search(IMAP4Search.ALL);
client.logout();
Implemantation of message get handler
// result for search method
private function uidList(event:IMAP4ListEvent):void{
for(var i:int = 0; i<event.length; i++){
var id:String = event.getValue(i);
client.message(id);
}
}
private function handleMessage(event:IMessageEvent):void{
var msg:MimeMessage = event.getMimeMessage();
trace("SUBJECT : " + msg.subjectUTF8);
}
IMessageEvent does not depends on IMAP4 API.
So you can handle the object like as POP3 API.

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.
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.
Regards
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.
Bhushan
This is a great library. How is the best way of retrieving the status \Seen, \Answered of a message?
Thanks
I wrote sample code for add flags and remove flags.
private function uidList(event:IMAP4ListEvent):void{
var id:String = event.getValue(i);
for(var i:int = 0; i
var flags:Array = [IMAP4Flag.SEEN, IMAP4Flag.ANSWERED ];
// TAG UID STORE 243 +FLAGS (\Seen \Answered)
client.addFlags(id,flags);
// TAG UID STORE 243 -FLAGS (\Seen \Answered)
client.removeFlags(id,flags);
}
}
IMAP4Flag.SEEN is static string.
So you can write
flags:Array = ["\\Seen","\\Answered"];
draft imap4 version has some bugs.
So please checkout sources from subversion or please wait a few days.
I’ll make 0.7 version swc file in a few days.
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.
Thanks
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.
Thanks
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.
>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
}
Thank you for such a quick fix.
Hi
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
Hi
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.
ex)
If you want to see recent mails…
client.selectMailbox(folder).search(IMAP4Search.FLAG_RECENT);
If you want to see unseen and recent mails…
client.selectMailbox(folder).search( IMAP4Search.and(IMAP4Search.FLAG_RECENT,IMAP4Search.FLAG_UNSEEN));
etc….
Hi:
ok, thank u very much…
Hi….
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?
Hello,
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
Regards,
Pranav
Hey,
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
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.
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!
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.
Regards