View Single Post
  #4 (permalink)  
Old 05-31-2009, 07:25 PM
fernandoflorez fernandoflorez is offline
Project Contributor
 
Posts: 250
Default

Here is another example i wrote quickly for Adobe Air:

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="absolute"
	applicationComplete="init();">
	
	<mx:Script>
		<![CDATA[
			
			import inca.api.Zimbra;
			import inca.api.events.*;
			import inca.api.models.*;
			
			private var $__zimbra:Zimbra = new Zimbra();
			private var $__zimbraMessage:ZimbraMessage;
			
			private function init():void{
				$__zimbra.server = "mail.domain.com";
				$__zimbra.username = "user@domain.com";
				$__zimbra.password = "myPassword";
				$__zimbra.addEventListener(ZimbraEvent.LOGGED_IN, onLoggedIn, false, 0, true);
				
				$__zimbra.login();
			}
			
			private function onLoggedIn(e:ZimbraEvent):void{
				(e.target as Zimbra).addEventListener(ZimbraSearchEvent.COMPLETE, onSearchComplete);
				
				(e.target as Zimbra).search("in:inbox", Zimbra.LIST_TYPE_MESSAGE, 1);
			}
			
			private function onSearchComplete(e:ZimbraSearchEvent):void{
				var messages:Array = (e.data as ZimbraSearchResponse).collection;
				
				$__zimbraMessage = $__zimbra.getMessage(messages[0].id);
				$__zimbraMessage.addEventListener(ZimbraEvent.MESSAGE_LOADED, onMessageLoaded);
			}
			
			private function onMessageLoaded(e:Event):void{
				var msg:ZimbraMessage = (e.target as ZimbraMessage);
				
				trace ("subject:", msg.subject, "\nmessage:", msg.content);
			}
			
			
		]]>
	</mx:Script>
	
</mx:WindowedApplication>
I didn't include try..catch blocks so if your search returns zero messages an error will be thrown.

Oh! BTW, i updated the library today to fix a bug on the folder listing.

Hope to have some free time this week to release the calendar part of the library.

Cheers!
Reply With Quote