0
 Atmail Mashup Tutorial - Using Java to list Mail, Contacts and Events

August 30, 2011

The Atmail API allows you to access and process data using your favorite language. For this tutorial we are going to use Java to query the Atmail API and process the JSON response to view mail, global contacts and calendar events from a webmail account.

This tutorial assumes that you already have one of the latest Java SDKs and Eclipse for Java Developers installed on your computer.

Download the source-code at: http://atmail.com/downloads/mashups/javaapi.tgz

Step-1: Download and extract the file onto your computer.

Step-2: Import the code into Eclipse.

Step-3: Replace the values in WebmailAPI.java to reflect the webmail account you wish to retrieve the data from.

Step-4: Run the code and the data will appear in the console.

java-api.PNG
How does it work?

The above mashup is a simple example which uses the Atmail API to download messages, contacts and calendar events in JSON format and displays them in a more readable format. A walk-through of the source-code  is below:

//Authenticate & Get session ID

//Set the url based on the basic variables
String urlString = domain + “index.php/mail/auth/processlogin?jsoncallback=true” + “&email=” + username + “&emailDomain=” + emailDomain +   “&emailName=” + emailName + “&requestedServer=” + requestedServer + “&password=” + password;

//Get data
String authenticationData = getDataFromUrlString(urlString);

//Decode the results
JSONObject jsonResult = null;

String sessionID = null;
try {
jsonResult = new JSONObject(authenticationData);
sessionID = (String) jsonResult.get(”SessionID”);
System.out.println(”Session ID: ” + sessionID);

} catch (JSONException e) {
System.out.println(”Error: ” + e.getMessage());
}

This part of the Java code uses the provided information to get a new Session ID  and prints it out.

//List mail
System.out.println(”\nMail:”);
urlString = domain + “index.php/api/mail/list/?SessionID=” + sessionID;
//Get data
String messageData = getDataFromUrlString(urlString);
//System.out.println(”Message Result: ” + messageData);

System.out.println(”Error: ” + e.getMessage());
}

This gets the mail data in JSON format, parses it and displays it.

//Query global address book- creating and displaying an array of up to the first 10 contacts
System.out.println(”\nGlobal Contacts:”);
//Set the url based on the domain name, action (listing contacts that are in the global group), session ID
//and which fields to return
urlString = domain + “index.php/api/contact/list/GroupID/-1/?SessionID=” + sessionID + “&Fields[]=UserFirstName&Fields[]=UserEmail&Fields[]=Favourite”;
//Get data
String contactData = getDataFromUrlString(urlString);

else{
System.out.println(”   ” + eventInformationFields[j] + “: ” + eventInformation.get(eventInformationFields[j]));
}

This does the same for global contacts and calendar events respectively.

Below are some ideas which could be incorporated for a real-world use of this mashup:

  • A user could create a backup of their messages, contacts and calendar events.
  • A program could be created that creates invitations using specific fields from the contacts.
  • A backup utility could be written in Java, to export a users mail/calendar/contact data to an external provider
  • A mashup could be created to pull users upcoming calendar events into a portal written in Java

The mashup API opens the gateways for possible extensions to Atmail -  We welcome your feedback and mashup submissions to include on our site.


Filed under: Frontpage, Plugins — Felicity @ 6:21 pm

3
 Atmail Mashup Tutorial - Creating a map of calendar events

August 21, 2011

The Atmail mashup API allows developers to create applications to access email, contact and calendaring data from the Atmail engine.

The API returns data in JSON format, which can be easily parsed by Javascript apps, PHP, Java, or any language you care to use.

A whole new world of possibilities open with the Atmail API - Developers can easily integrate Atmail into a corporate Intranet, consumer portal for an ISP, web-mashup on an existing web-site or pull Atmail data into existing applications.
For this tutorial we are going to walkthrough a sample to pull calendar events, and pin-point the location of each event on a map.

View an online demo at: http://atmail.com/downloads/mashups/atmailmappa/index.html

Download the source-code at: http://atmail.com/downloads/mashups/atmailmappa.tgz

Step-1: Download and extract the atmailmappa.tgz into your existing web-site, e.g mydomain.com/atmailmappa/

Step-2: Signup for a Google Maps API key and replace the following in the index.html

http://maps.google.com/maps?file=api&v=2&sensor=true&key=MYAPIKEY

Step-3: Edit the index.html and define your URL to the Atmail Webmail instance

var url = ‘http://a6demo.atmail.com/’;

Step-4: Next, if you are using the mashup outside of your Atmail Webmail domain ( e.g http://portal.company.com ) you must query the server using JSON-P. This allows Javascript to load data outside of its local domain. To enable JSON-P make sure this is toggled on via the Atmail Webadmin > Services > API Access > JSON-P = On

If you will be querying the Atmail mashup API outside of your local domain, define the following below the URL call:

$(this).setjsoncallback(1); // Set to 1 for JSON-P, or 0 for regular JSON

Step-5: Login to your local Atmail Webmail instance with a valid username/password. Visit the Calendar tab and create various appointments with an address defined in the ‘Location’ field

Add event with location

Step6: Reload the URL you installed the atmailmappa.tgz and you will see a Google map with the location of events you created via the Webmail interface!

Mashup sample of events on a map
How does it work?

The above mashup is a simple example which uses the Atmail calendar API to download a list of events in JSON format and plunk the location and event name to insert onto a copy. A walk-through of the source-code is below:

    var url = ‘http://a6demo.atmail.com/’;

$(this).setjsoncallback(1);

$(”A.login”).bind(’click’, function() {
location.href= url;
});

$(”BODY”).checkLogin({
url: url,
error: function() {
$(”DIV.login”).fadeIn(’fast’);
},

The first part of the Javascript loads an authentcation request as the specified domain. The checkLogin function will validate if an existing cookie/sessionId exists and will pre-authenticate the user. If no valid Atmail sessionId/cookie is found, the login DIV will fade to the display prompting the user to first login.

    success: function() {

    var calendarUrl = url + “index.php/api/calendar/list/” + $(this).jsoncallback();
    var params = { format: ‘json’ };

    var locations = new Array();
    var i=0;
    $.getJSON(calendarUrl, params, function(json) {
    if ( json ) {
    $.each( json, function(i, n) {
    var item = json[i];

    if(item.Location != ‘’) {
    locations.push({address: item.Location, html: item.Title + ‘
    ‘ + item.DateStartCal + ‘ ‘ + item.DateStartTime + ‘
    (’ + item.Location + ‘)’});
    i++;
    }

});

Next, on success of an authentication request, the function will request a list of calendar events from the Atmail API. The data is returned in a JSON packet, which is looped as an array. For each calendar event with a location field defined, the locations array will expand with the address location and title of the event. Interesting attributes for the calendar entry include item.Title, item.Location and item.DateStartCal and item.DateStartTime

$(”#map”).gMap({ markers: locations, zoom: 12});

Lastly, once a location in the calendar has been defined we map the result using the excellent jQuery plugin gMap.

Below are some ideas which could be incorporated for a real-world use of the calendar mashup:

  • A logistics company could supply drivers with an iPhone with the native calendar-app communicating to the CalDAV server of Atmail. Each pickup/delivery would be a calendar event with an assigned location. Back at HQ the mashup could provide an overview map display of all active pickup/deliveries for the day for management to monitor and keep updated in the field.
  • A musician may keep track of upcoming events using the Atmail calendar using Atmail Webmail and publish a mashup of the calendar map on their website sidebar. Visitors to the site will be able to see upcoming gigs on a map, based on their current location.
  • Sales consultant in the field could keep track of events using the Atmail calendar (desktop CalDAV apps, mobile or WebUI) and map their upcoming meetings on a map.

The mashup API opens the gateways for possible extensions to Atmail - We welcome your feedback and mashup submissions to include on our site.


Filed under: Frontpage — Ben Duncan @ 11:34 pm

1
 Atmail 6.20.11 now available.

August 12, 2011

Atmail 6.20.11 is now available for download. Free for Atmail license holders.

What does this mean for your Atmail installation? For this release, we’ve focused on improved email rendering. Atmail has improved the display of various types of email messages. HTML content looks better, and issues with malformed content have been resolved.

Atmail translations have received an overhaul; Javascript content is now included in the translation process. Some translation packs have been updated to mirror this change. In addition, this version contains many fixes for issues within the webmail interface. Read the changelog for the full details.

Follow these steps to update your Atmail installation. If you have any questions, do not hesitate to contact our support team.


Filed under: Frontpage, Atmail 6 — John Contad @ 1:37 am

4
 Seeking new translations for Atmail - 50% discount offer

We are seeking new translations for Atmail 6 - Are you an existing customer, web-developer, ISP, or a user which is interested to help translate Atmail?

If so, we can provide you a 50% discount on any version of Atmail in return for a complete translation of the Atmail language pack.

The primary languages we are seeking are Spanish, Italian, French, Portuguese, Arabic, and Dutch. Any other language is welcome!

Ordering and Pricing, including the 50% discount:
http://atmail.com/order.php?DiscountCode=LANG-LBD

Translating Guide:
http://atmail.com/wiki/doku.php?id=atmail6:translationguide

Please feel free to contact us for further details. The language discount will be provided to the first come, first served basis.


Filed under: Frontpage, Atmail 6 — Ben Duncan @ 12:55 am

0
 New developer jobs available - PHP, iOS and Android developers required

August 9, 2011

As Atmail continues to grow, we require new developers to expand our product-line and help develop new mobile clients based on the iOS/Android platform. Atmail is announcing three job openings starting immediately, and looking for some amazing developers to join our team!

Peregian Beach - Atmail R&D Labs

Tired of the daily commute and want a fresh and existing job for a leading software vendor?

Join our vibrant development team based at the Atmail R&D Labs in Peregian Beach, Australia - Enjoy coding, sun and a beach lifestyle. Positions are available on-site, and remote-work applications will be considered on a merit basis. Local and international applicants are welcome, and developers of active open-source projects a bonus.
Email your resume to jobs@staff.atmail.com - Applications close 24th Aug.

Senior PHP Developer

We are seeking a senior developer to join the Atmail team. You will be working on the Atmail Webmail and Atmail server product-line developing new-features and assisting with bug-fixes, enhancements and optimizations to the code-base.

Skill-set required:

  • PHP - Solid foundation in PHP required
  • jQuery - Experience using jQuery for Ajax applications
  • Linux experience - Using Apache, mySQL, building high-scale and reliable systems
  • Experience with the Zend Framework
  • Experience using Atlassian JIRA/Bamboo a bonus

The position is for full-time employment

iOS Developer

Atmail are developing mobile messaging software for iOS for email, contacts, calendaring and voice/video. We require a lead developer to assist with the rollout of the new products

Skill-set required:

  • 1 year minimum experience with Objective C
  • Experience with JSON
  • Familiar with the XCode environment
  • Knowledge of SIP protocol
  • Experience with audio/video codecs

The position is for a 6-month contract, extendable to full-time employment based on results.

Android Developer

Atmail are developing mobile messaging software for Android for email, contacts, calendaring and voice/video. We require a lead developer to assist with the rollout of the new products based on the Android platform

Skill-set required:

  • Strong Java experience
  • 1 year minimum experience with the Android SDK
  • Experience with JSON
  • Knowledge of SIP protocol
  • Experience with audio/video codecs

The position is for a 6-month contract, extendable to full-time employment based on results.

Interested in joining the Atmail team? Send us your resume via email to jobs@staff.atmail.com


Filed under: Software Development, Staff Opinions, Frontpage — Ben Duncan @ 7:08 pm