Archive for 11月, 2010

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

If you want to know how to get e-mail message.
Please refer to HERE.

private	function messageHandler(e:POP3MessageEvent):void{
	var msg:MimeMessage = e.getMimeMessage();
	//  attachmentChildren are only parts has attachments files.
	//  Don't need to check all children to extract files
	
	var attaches:Array = msg.attachmentChildren;
	if(attaches.length > 0){
		for each(var attach:MimeBodyPart in attaches){
			if(attach is MimeBinaryPart){
				var binPart:MimeBinaryPart = attach as MimeImagePart;
				var bytes:ByteArray = attach.bodyByteArray;
				
				//  v0.5 and less than r69 version has BUG !!
				//  binPart.getHeader("Content-Disposition"); is both available
				
				var contentDisposition:MimeHeader = binPart.contentDisposition;
				
				if(contentDisposition){
					var filename:String = contentDisposition.getParameter("filename");
					filename = MimeUtils.decodeMimeHeader(filename);
					log.debug("Filename => " + filename );
					
					//  save Desktop directory, plese change following codes as you like
				
					var file:File =	File.desktopDirectory.resolvePath(filename);
					var fs:FileStream = new	FileStream();
					fs.open(file,FileMode.APPEND);
					fs.writeBytes(bytes);
					fs.close();
				}
			}
		}
	}
}
Problem

You need to change flex sdk directory ( flex version ) in ANT build.xml file without specifying absolute directory path.

1) use Flex Builder 3 or Flash Builder 4 ‘s Flex SDK directory

2) use enviroment variable

<!--  use 'env' as enviroment variable  -->
<property environment="env" />

<!--  Default Flex SDK directory -->
<property name="FLEX_SDK" value="C:\Flex\sdk\3.5.0.12683" />

<!-- Set SDK directory from enviroment variable -->
<condition property="FLEX_HOME" value="${env.FLEX_HOME}">
  <isset property="env.FLEX_HOME" />
</condition>
	
<!--  
set Flash(Flex) Builder's SDK directory 
In my case value is 'C:\Program Files (x86)\Adobe\Adobe Flash Builder 4\sdks\4.1.0' 
-->
<condition property="FLEX_HOME" value="${application.home}">
  <isset property="application.home" />
</condition>

<target name="compc">
     <echo>FLEX_HOME: ${FLEX_HOME}</echo>
     <compc output="dist/swcfilename.swc">
          <load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />
          <source-path path-element="${basedir}/src" />
          <include-sources dir="${basedir}/src" includes="*" />
          <include-libraries file="${basedir}/libs" />
     </compc>
</target>

You can see complete build.xml file at HERE.

Point1

condition tag.

<condition property="FLEX_HOME" value="${application.home}">
  <isset property="application.home" />
</condition>
Point2

When you execute ‘ant’ , please check
[Run in the same JRE as the workspace]

Flash(Flex) builder does not include ANT view by default,
So please see the blog or search yourself.

RSS
Add to Google
2010年11月
« 8月   12月 »
 123456
78910111213
14151617181920
21222324252627
282930